如何找到Spring Data JPA和Spring版本的正确jar文件

我正在使用Spring MVC和Spring Data JPA,并且面临jar版本的异常。

这是我的pom:

<properties>

<spring.version>4.2.4.RELEASE</spring.version>

<hibernate.version>4.3.8.Final</hibernate.version>

<mysql.version>5.1.10</mysql.version>

<junit-version>4.11</junit-version>

<servlet-api-version>3.1.0</servlet-api-version>

<spring-security-version>4.0.4.RELEASE</spring-security-version>

<spring-data-solr.verion>1.2.0.RELEASE</spring-data-solr.verion>

<springbatch.version>3.0.6.RELEASE</springbatch.version>

<jsp-version>2.1</jsp-version>

<jstl-version>1.2</jstl-version>

<java.version>1.7</java.version>

<liquibase.version>3.1.1</liquibase.version>

<spring.data.jpa.version>1.10.3.RELEASE</spring.data.jpa.version>

<spring.social.version>1.1.0.RELEASE</spring.social.version>

</properties>

这是我的课:

import org.springframework.data.jpa.repository.JpaRepository;

public interface RoleRepository extends JpaRepository<Role, Long> {

}

我在Eclipse上收到一条错误警告,并显示以下消息:

The type org.springframework.data.repository.query.QueryByExampleExecutor cannot be resolved. It is indirectly referenced from required .class files

看来我的Spring数据jpa jar版本不正确,但是我不知道找到正确的版本。我的spring版本:4.2.4.RELEASE是最新的

如何解决这个错误?非常感谢 !

回答:

由于您拥有POM,这意味着您正在使用Maven,并且Maven拥有一个名为dependency的插件,您可以在其上调用dependency:list该插件,该插件将列出所有jar依赖项及其版本。

只需在项目的根目录中调用(假设您使用的是启动器):

./mvnw dependency:list

您将列出您的jar:

[INFO] ------------------------------------------------------------------------

[INFO] Building XXXXXXX 0.0.2-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-dependency-plugin:2.10:list (default-cli) @ xxxxxxx ---

[INFO]

[INFO] The following files have been resolved:

[INFO] org.apache.lucene:lucene-backward-codecs:jar:5.5.2:compile

[INFO] org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.1.RELEASE:compile

你也可以使用dependency:analyze-duplicatedependency:tree或者dependency:analyze-

report检查一切声明一次。检查此插件的文档,当您遇到依赖关系问题时,它确实很有用。

这是dependency:tree的示例:

[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ ouaknine ---

[INFO] com.rdlopes.ouaknine:ouaknine:war:0.0.2-SNAPSHOT

[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:jar:2.8.6:compile

[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.6:compile

[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile

[INFO] | \- javax.transaction:jta:jar:1.1:compile

[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-hppc:jar:2.8.6:compile

[INFO] | \- com.carrotsearch:hppc:jar:0.7.1:compile

[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-json-org:jar:2.8.6:compile

[INFO] | \- org.apache.geronimo.bundles:json:jar:20090211_1:compile

[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.6:compile

[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile

[INFO] +- com.h2database:h2:jar:1.4.193:compile

[INFO] +- com.jayway.jsonpath:json-path:jar:2.2.0:test

[INFO] | +- net.minidev:json-smart:jar:2.2.1:test

[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test

[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:test

[INFO] | \- org.slf4j:slf4j-api:jar:1.7.22:compile

[INFO] +- com.jcraft:jzlib:jar:1.1.3:compile

[INFO] +- com.mattbertolini:liquibase-slf4j:jar:2.0.0:compile

[INFO] +- com.ryantenney.metrics:metrics-spring:jar:3.1.3:compile

[INFO] | +- io.dropwizard.metrics:metrics-healthchecks:jar:3.1.2:compile

[INFO] | +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile

[INFO] | +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile

[INFO] | \- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile

[INFO] +- com.zaxxer:HikariCP:jar:2.6.0:compile

[INFO] +- commons-io:commons-io:jar:2.5:compile

[INFO] +- io.dropwizard.metrics:metrics-annotation:jar:3.1.2:compile

[INFO] +- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile

[INFO] +- io.dropwizard.metrics:metrics-json:jar:3.1.2:compile

在我的MacBook Pro上,我只需在终端中致电:

macbook-pro-de-rui:ouaknine rui$ ./mvnw dependency:list | grep jpa

[INFO] org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile

[INFO] org.springframework.data:spring-data-jpa:jar:1.11.0.RELEASE:compile

[INFO] org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.1.RELEASE:compile

以上是 如何找到Spring Data JPA和Spring版本的正确jar文件 的全部内容, 来源链接: utcz.com/qa/426046.html

回到顶部