Java 具有Spring Boot Starter父级的多模块Maven项目结构

Java 具有Spring Boot Starter父级的多模块Maven项目结构,java,spring,maven,spring-mvc,Java,Spring,Maven,Spring Mvc,好的,我马上就开始。我有一个使用spring的多模块maven项目。项目结构可概括如下: Project Root |--common module |----src |----pom.xml |--module 1 |----src |----pom.xml |--module 2 |----src |----pom.xml |-pom.xml 在本例中,我将根级别pom文件声明spring boot starter为父级: <groupId>com.example.stacko

好的,我马上就开始。我有一个使用spring的多模块maven项目。项目结构可概括如下:

Project Root
|--common module
|----src
|----pom.xml
|--module 1
|----src
|----pom.xml
|--module 2
|----src
|----pom.xml
|-pom.xml
在本例中,我将根级别pom文件声明spring boot starter为父级:

<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>
似乎spring boot starter父代的pom正在执行我不想执行的额外任务

如果您需要why和what,则模块是特定的REST服务,公共模块包含共享DTO和它们共同的持久性对象。在我看来,我有几个选择:

  • 我可以分离出依赖项,以便模块1和模块2将spring boot starter父级作为它们的父级,并从根pom中删除spring boot starter,从而释放公共资源

  • 我可以删除根pom作为公共的父级

  • 我可以手动构建spring boot starter在项目中所做的一切


  • 这些选项中哪一个是最好的,或者是否有一个我不认为更可取的选项

    Spring boot具有maven版本。如果它包含在您的pom中。删除它并尝试

    <parent>
        <groupId>com.example.stackoverflow</groupId>
        <artifactId>indiana-jones</artifactId>
        <version>VersionNumber</version>
    </parent>
    
    <artifactId>module-1</artifactId>
    
    [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