2016-10-30 28 views
1

我有一個Spring Module 1.3.8的多模塊項目。目前我想更新到1.4.1,但目前很痛苦,因爲querydsl,thyemeleaf,hibernate等其他幾個主要升級。Spring Boot覆蓋第三方依賴版本

因此,我發現您可以在Spring Boot 1.3.8中使用Hibernate 5的信息,您只需要在屬性中覆蓋hibernate的版本號。 (例如:enter link description here

我在父POM做:

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

這就是春天的啓動依賴關係的依賴管理下宣佈同POM:

<dependencyManagement> 
     <dependencies> 

      <!-- SPRING-BOOT ... --> 
      <dependency> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-dependencies</artifactId> 
       <type>pom</type> 
       <version>${org.springframework.boot-version}</version> 
       <scope>import</scope> 
      </dependency> 

      .... 

在我的子模塊我仍然有 enter image description here

我也嘗試將<hibernate.version>5.0.11.Final</hibernate.version>添加到子模塊p OM。也沒有變化。

我錯過了什麼?

+0

我認爲這與「進口彈簧引導依賴的POM」做VS宣告春天開機起動父父(其中你的屬性將覆蓋父母的一個) – alexbt

+0

你有 spring-boot-starter-parent? – alexbt

+0

嘿亞歷克斯,謝謝你的回答,只是在努力。在父pom中添加spring-boot-starter-parent作爲父項具有以下效果:-)我只是試用了,我需要它們兩個或只有其中一個 –

回答

2

屬性重寫僅在將spring-boot聲明爲父類時才起作用。

使用以下(從Spring-Boot documentation拍攝):

<?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> 

    <!-- Inherit defaults from Spring Boot --> 
    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.3.8.RELEASE</version> 
    </parent> 

    <groupId>com.example</groupId> 
    <artifactId>myproject</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 

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

    <!-- Add typical dependencies for a web application --> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
    </dependencies> 

    <!-- Package as an executable jar --> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 

</project> 
+0

嘿Alex,works對我來說,謝謝你:-) –

+0

嘿亞歷克斯,我只知道爲什麼我沒有使用父標籤進行spring啓動,因爲我的項目有多個模塊嵌套到2級。當您使用解決方案中提到的Spring Boot時,您將成爲第二級問題。您的解決方案是有效的,但不適用於嵌套超過1級的項目。 –

+0

嘿亞歷克斯,你的解決方案似乎也適用於嵌套。 –

相關問題