Spring Boot:受管版本是1.3.2.RELEASE该工件在org.springframework.boot中进行管理:spring-boot-dependencies:1.3.2.RELEASE [英] Spring Boot: The managed version is 1.3.2.RELEASE The artifact is managed in org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE

查看:1060
本文介绍了Spring Boot:受管版本是1.3.2.RELEASE该工件在org.springframework.boot中进行管理:spring-boot-dependencies:1.3.2.RELEASE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 <?xml version = 1.0encoding =UTF-8?> 
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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>

< 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 /> <! - 从存储库查找父级 - >
< / parent>

<属性>
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
< java.version> 1.8< /java.version>
< / properties>

<依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-data-jpa< / artifactId>
< /依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-jdbc< / artifactId>
< /依赖关系>
< dependency>
< groupId> org.projectlombok< / groupId>
< artifactId> lombok< / artifactId>
< version> 1.16.6< / version>
< /依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-thymeleaf< / artifactId>
< /依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-web< / artifactId>
< /依赖关系>

< dependency>
< groupId> mysql< / groupId>
< artifactId> mysql-connector-java< / artifactId>
< scope>运行时< / scope>
< /依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-tomcat< / artifactId>
< scope>提供< / scope>
< /依赖关系>
< dependency>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-test< / artifactId>
< scope> test< / scope>
< /依赖关系>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 5.1.0.Final< / version>
< /依赖关系>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< /依赖关系>
< /依赖关系>

< 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




帮我解决这些问题。

解决方案

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 property:

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

这将确保Spring Boot提供依赖管理的所有Hibernate模块都具有所需的版本。 / p>

最后请注意。 Hibernate 5.1非常新,包含一些重大更改,甚至包括5.0.x.因此,您可能会遇到一些不兼容问题。如果你不想在流血的边缘上正确的话,5.0.x可能是一个更安全的选择。它将成为Spring Boot 1.4中的默认Hibernate版本。


I create a skeleton application use Spring boot. This is my 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>

I stuck at this step:

Spring Boot: The managed version is 1.3.2.RELEASE The artifact is managed in org.springframework.boot:spring-boot-dependencies:1.3.2.RELEASE

When I try add Hiberante 5.1.0.Final manually, this notice appear:

Overriding managed version 4.3.11.Final for hibernate-core

Help me resolve these problem.

解决方案

Spring Boot provides dependency management for Hibernate. The warning is Eclipse telling you that you've overridden this dependency management by declaring a version directly on a dependency. That's a risky thing to do as you may end up with a mixture of Hibernate versions on the classpath. In fact, looking at your pom, you've overridden the version of hibernate-core but not of hibernate-entitymanager. This means you'll have 5.1.0.Final of the former and 4.3.11.Final of the latter on the classpath. That will almost certainly lead to problems at runtime.

A safer way to use Hibernate 5 is to override Boot's dependency management. As you are using spring-boot-starter-parent as your pom's parent you can do that by overriding the hibernate.version property:

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

This will ensure that all Hibernate modules for which Spring Boot provides dependency management will have the desired version.

Finally, a note of caution. Hibernate 5.1 is very new and contains some breaking changes, even from 5.0.x. As a result, you may run into some incompatibility problems. If you don't want to be right on the bleeding edge, 5.0.x may be a safer choice. It will become the default Hibernate version in Spring Boot 1.4.

这篇关于Spring Boot:受管版本是1.3.2.RELEASE该工件在org.springframework.boot中进行管理:spring-boot-dependencies:1.3.2.RELEASE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆