美文网首页
springboot多模块项目构建

springboot多模块项目构建

作者: 早点起床晒太阳 | 来源:发表于2020-10-23 20:21 被阅读0次

参考资料
https://juejin.im/post/6844903893487321101

基础架构

父module

创建一个springboot的项目,然后将src等乱七八糟的删掉,只剩下pom

pom相关
1、声明module模块
2、在pom 添加<packaging>pom</packaging>

部分代码

    <groupId>com.example</groupId>
    <artifactId>moremodule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>moremodule</name>
    <packaging>pom</packaging>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <modules>
        <module>common</module>
        <module>test</module>
    </modules>

子module

通过new module创造子springboot项目

1、需要将pom中的<parent> 该为父module的(所有的子模块都需要改)
2、如果子module中需要相互依赖,需要将依赖放到dependencies中依赖上就可以,示例如下

    <parent>
        <groupId>com.example</groupId>
        <artifactId>moremodule</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

相关文章

网友评论

      本文标题:springboot多模块项目构建

      本文链接:https://www.haomeiwen.com/subject/phlbmktx.html