2017-02-16 54 views
1

好的,我會馬上進入它。我有一個使用spring的多模塊maven項目。項目結構可以概括爲這樣:帶有Spring-Boot-Starter-Parent的多模塊Maven項目結構

Project Root 
|--common module 
|----src 
|----pom.xml 
|--module 1 
|----src 
|----pom.xml 
|--module 2 
|----src 
|----pom.xml 
|-pom.xml 

在這種情況下,我有根級POM文件中聲明彈簧引導起動作爲父:

<groupId>com.example.stackoverflow</groupId> 
<artifactId>indania-jones</artifactId> 
<version>VersionNumber</version> 
<packaging>pom</packaging> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.2.RELEASE</version> 
</parent> 

子模塊有根pom作爲他們的父母。

<parent> 
    <groupId>com.example.stackoverflow</groupId> 
    <artifactId>indiana-jones</artifactId> 
    <version>VersionNumber</version> 
</parent> 

<artifactId>module-1</artifactId> 

在這種簡化的情況下,模塊1和模塊2也具有公共模塊作爲依賴關係。當試圖在本地運行時,我在公共模塊上使用mvn install,以便可以運行其他兩個模塊。問題是,當我運行常見的mvn安裝失敗。

[ERROR] Failed to execute goal org.springframework.boot:spring-boot- maven-plugin:1.3.2.RELEASE:repackage (default) on project q-common: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.2.RELEASE:repackage failed: Unable to find main class -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

看起來好像春季啓動啓動父母的pom執行額外的職責,我不想執行。

如果您需要爲什麼和什麼,模塊是特定的REST服務,並且通用模塊包含共享的DTO和持久性對象,這兩個對象通用。在我看來,我有幾個選擇:

  1. 我可以分離出依賴關係,以便模塊1和模塊2具有彈簧引導起動父母爲他們的父母,並從取出彈簧引導啓動根源,從而解放共同。

  2. 我可以刪除根目錄作爲常見的父項目。

  3. 我可以手動構建spring-boot-starter在項目中所做的一切。

哪一個選項是最好的,還是有一個選項我沒有看到這是可取的?

回答

1

Spring-boot有maven build plugin。如果它包含在你的pom中。刪除它並嘗試。