Spring Boot:托管版本为1.3.2.RELEASE工件在org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE中进行管

【字号: 日期:2024-03-24浏览:52作者:雯心
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决Spring Boot:托管版本为1.3.2.RELEASE工件在org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE中进行管理?

Spring Boot为Hibernate提供了依赖管理。警告是Eclipse告诉您已经通过直接在依赖项上声明一个版本来覆盖此依赖项管理。这是一件冒险的事情,因为您可能最终在类路径上混合了Hibernate版本。实际上,查看pom时,您已经覆盖了hibernate-core的版本,而不是hibernate-entitymanager的版本。这意味着您将在类路径上拥有前者的5.1.0.Final和后者的4.3.11.Final。这几乎肯定会导致运行时出现问题。

使用Hibernate 5的一种更安全的方法是覆盖Boot的依赖项管理。当您spring-boot-starter-parent作为pom的父母时,可以通过覆盖hibernate.version属性来做到这一点:

<properties> <hibernate.version>5.1.0.Final</hibernate.version></properties>

这将确保Spring Boot为其提供依赖关系管理的所有Hibernate模块都具有所需的版本。

最后,请注意。Hibernate 5.1是一个非常新的版本,甚至从5.0.x开始都包含一些重大更改。结果,您可能会遇到一些不兼容的问题。如果你不想成为权在流血的边缘,5.0.x的可能是更安全的选择。在Spring Boot1.4中它将成为默认的Hibernate 版本。

解决方法

我使用Spring Boot创建一个框架应用程序。这是我的pom.xml

<?xml version='1.0' encoding='UTF-8'?><project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd'> <modelVersion>4.0.0</modelVersion> <groupId>com.lynas</groupId> <artifactId>SpringMVCHibernate</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>SpringMVCHibernate</name> <description>SpringMVCHibernate</description> <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.3.2.RELEASE</version><relativePath /> <!-- lookup parent from repository --> </parent> <properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version> </properties> <dependencies><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.6</version></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope></dependency><dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.1.0.Final</version></dependency><dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId></dependency> </dependencies> <build><plugins> <plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId> </plugin></plugins> </build></project>

我停留在这一步:

Spring Boot:托管版本为1.3.2.RELEASE。工件在org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE中进行管理

相关文章: