Spring Boot如何提供spring-data-jpa v1.10.3.RELEASE
How does Spring Boot provide spring-data-jpa v1.10.3.RELEASE
我有一个带有 POM 的项目,它指定了对 spring-data-jpa 的依赖,如下所示:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
它与版本号无关,但是当我 运行 mvn:dependency:tree
我可以看到如下相关部分...
| \- org.springframework:spring-orm:jar:4.3.3.RELEASE:compile
[INFO] +- **org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE**:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.3.RELEASE:compile
[INFO] | \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
...它显示它是 1.10 版本。3.RELEASE。
不知道最后是怎么带版本号的。我查了一下,它既不是最新的 Maven Repository 的 Spring Data JPA 版本号,也不是其父 POM 中定义该依赖项的部分。项目 POM 如下所示:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
spring-data-jpa
的版本由spring-boot-parent提供。
您可以在appendix-dependency-versions section of the Spring Boot docs.
中看到spring-boot版本和spring-data-jpa
之间的关系
比如最新版本的Spring Boot会提供1.11.9.RELEASE
的spring-data-jpa
版本。
在你的问题中你显示:org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE
这表明你使用的是Spring Boot的v1.4.x,相关的依赖关系在docs for v1.4.1 of Spring Boot中显示:
org.springframework.data spring-data-jpa 1.10.3.RELEASE
spring-boot
1.4.1.RELEASE 和 spring-data-jpa
1.10.3.RELEASE 之间的关系是由 Maven 促进的,因为 Maven 遵循 Spring 中定义的关系Boot 的 POM。
来自the docs(我的重点):
Each release of Spring Boot provides a curated list of dependencies that it supports. In practice, you do not need to provide a version for any of these dependencies in your build configuration, as Spring Boot manages that for you.
The curated list contains all the spring modules that you can use with Spring Boot as well as a refined list of third party libraries. The list is available as a standard Bills of Materials (spring-boot-dependencies) that can be used with both Maven and Gradle.
因此,Spring Boot 为您提供了 spring-boot-starter-data-jpa
,而后者又通过对 spring-data-releasetrain
的依赖提供了 spring-data-jpa
。精确的机制是:
spring-boot-starter-data-jpa
声明对 spring-data-jpa
. 的依赖
spring-boot-starter-data-jpa
的父级是 spring-boot-starters
spring-boot-starters
的父级是 spring-boot-parent
spring-boot-parent
的父级是 spring-boot-dependencies
spring-boot-dependencies
导入 spring-data-releasetrain
POM:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>${spring-data-releasetrain.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
我有一个带有 POM 的项目,它指定了对 spring-data-jpa 的依赖,如下所示:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
它与版本号无关,但是当我 运行 mvn:dependency:tree
我可以看到如下相关部分...
| \- org.springframework:spring-orm:jar:4.3.3.RELEASE:compile
[INFO] +- **org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE**:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.3.RELEASE:compile
[INFO] | \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
...它显示它是 1.10 版本。3.RELEASE。
不知道最后是怎么带版本号的。我查了一下,它既不是最新的 Maven Repository 的 Spring Data JPA 版本号,也不是其父 POM 中定义该依赖项的部分。项目 POM 如下所示:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${springboot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
spring-data-jpa
的版本由spring-boot-parent提供。
您可以在appendix-dependency-versions section of the Spring Boot docs.
中看到spring-boot版本和spring-data-jpa
之间的关系
比如最新版本的Spring Boot会提供1.11.9.RELEASE
的spring-data-jpa
版本。
在你的问题中你显示:org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE
这表明你使用的是Spring Boot的v1.4.x,相关的依赖关系在docs for v1.4.1 of Spring Boot中显示:
org.springframework.data spring-data-jpa
1.10.3.RELEASE
spring-boot
1.4.1.RELEASE 和 spring-data-jpa
1.10.3.RELEASE 之间的关系是由 Maven 促进的,因为 Maven 遵循 Spring 中定义的关系Boot 的 POM。
来自the docs(我的重点):
Each release of Spring Boot provides a curated list of dependencies that it supports. In practice, you do not need to provide a version for any of these dependencies in your build configuration, as Spring Boot manages that for you.
The curated list contains all the spring modules that you can use with Spring Boot as well as a refined list of third party libraries. The list is available as a standard Bills of Materials (spring-boot-dependencies) that can be used with both Maven and Gradle.
因此,Spring Boot 为您提供了 spring-boot-starter-data-jpa
,而后者又通过对 spring-data-releasetrain
的依赖提供了 spring-data-jpa
。精确的机制是:
spring-boot-starter-data-jpa
声明对spring-data-jpa
. 的依赖
spring-boot-starter-data-jpa
的父级是spring-boot-starters
spring-boot-starters
的父级是spring-boot-parent
spring-boot-parent
的父级是spring-boot-dependencies
spring-boot-dependencies
导入spring-data-releasetrain
POM:<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>${spring-data-releasetrain.version}</version> <scope>import</scope> <type>pom</type> </dependency>