简体   繁体   English

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

[英]How to find correct jar file of Spring Data JPA and Spring version

I'm using Spring MVC and Spring Data JPA and facing with an exception of jar version. 我正在使用Spring MVC和Spring Data JPA,并且面临jar版本的异常。

This is my pom: 这是我的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>

This is my class: 这是我的课:

import org.springframework.data.jpa.repository.JpaRepository;
public interface RoleRepository extends JpaRepository<Role, Long> {

}

I received an error warning on Eclipse with message: 我在Eclipse上收到一条错误警告,并显示以下消息:

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

It seem my Spring data jpa jar version is incorrect, but I don't know find correct version. 看来我的Spring数据jpa jar版本不正确,但是我不知道找到正确的版本。 My Spring verion: 4.2.4.RELEASE is latest 我的春季版本:4.2.4.RELEASE是最新的

How to fix this error? 如何解决这个错误? Thank so much ! 非常感谢 !

The place to go to find the version compatibility is https://www.mvnrepository.com/ You put in your version and it will show the associated libs and their versions. 查找版本兼容性的地方是https://www.mvnrepository.com/ 。您输入了版本,它将显示相关的库及其版本。 Cool site. 很酷的网站。 It will even show you how to enter your POM. 它甚至还会向您展示如何输入您的POM。 For your spring data jpa, I entered "Spring data jpa" in the search, clicked on the library, then clicked on your version "1.10.3". 对于您的spring data jpa,我在搜索中输入了“ Spring data jpa”,单击了库,然后单击了您的版本“ 1.10.3”。 If you scroll to the bottom, it will show the associated compile dependencies and their versions. 如果滚动到底部,它将显示关联的编译依赖项及其版本。

Since you have a POM, it means you're using Maven, and Maven has a plugin called dependency on which you can call dependency:list that will list all your jar dependencies together with their versions. 由于您拥有POM,这意味着您正在使用Maven,并且Maven拥有一个名为Dependency的插件,您可以在其上调用dependency:list ,该列表将列出所有jar依赖项及其版本。

Just call at the root of your project (given that you're using a starter): 只需在项目的根目录中调用(假设您使用的是启动器):

./mvnw dependency:list

and you will list your jars: 您将列出您的罐子:

[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

You can also use dependency:analyze-duplicate , dependency:tree or dependency:analyze-report to check everything is declared once. 您还可以使用dependency:analyze-duplicatedependency:treedependency:analyze-report来检查是否声明了所有内容。 Check the documentation for this plugin, it is really useful when you're facing dependencies issues. 检查此插件的文档 ,当您遇到依赖关系问题时,它确实很有用。

Here's a sample of dependency:tree: 这是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

On my MacBook Pro, I simply call in the Terminal: 在我的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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 spring-data-jpa 获取这些数据如何更正确? - How is more correct to get this data with spring-data-jpa? jar文件中的Spring JPA Autoscan实体 - Spring JPA Autoscan entities in jar file Spring 数据 JPA:有什么问题或如何更正此 jpql 查询 - Spring Data JPA: What is wrong or how to correct this jpql query Spring Boot,Spring Data JPA,CrudRepository,基于文件的只读数据库,打包在JAR中 - Spring Boot, Spring Data JPA, CrudRepository, file based read only database packaged in JAR 如何检查 Postgres 版本与 spring data jpa 的兼容性? - How to check Postgres version compatibility with spring data jpa? 如果我在 Spring JPA Gradle 项目的 Jar 文件中找不到 jks 文件怎么办? - What if I can't find the jks file in Jar file on Spring JPA Gradle Project? 为什么没有使用Spring Data JPA设置版本属性? - Why is the version property not set with Spring Data JPA? 如何找到 Hibernate + Spring-JPA 的兼容版本对? (无法打开 JPA EntityManager 进行交易) - How to find compatible version pair of Hibernate + Spring-JPA? (Could not open JPA EntityManager for transaction) 如何在一个参数中找到多个项目Spring数据jpa - How to find many item in one parameter Spring data jpa 如何在 Spring Data JPA 中找到具有 OneToMany 关系的 cortege - How to find cortege with OneToMany relation in Spring Data JPA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM