第二十一节 SpringBoot多项目打包

一、使用 Intellij IDEA 工具的Maven插件打包思路

        项目整体结构如下。分为authentication、core、service、web四个大模块。

        core负责核心Java公用配置,例如分页拦截器、Datasource等。

        service、authentication这两个模块负责业务。

         web封装了启动类,并且将所有的配置文件都配置在这里。

        

在web模块的pom.xml,只有它有build节点配置。在最外层father模块不用配置build节点。


    <parent>
        <artifactId>father</artifactId>
        <groupId>com.tyzhou</groupId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>web</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.tyzhou</groupId>
            <artifactId>service</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.tyzhou</groupId>
            <artifactId>core</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.tyzhou</groupId>
            <artifactId>authentication</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>packageDemo-${version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.tyzhou.FatherApplication</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

二、各模块独自打包

        下面我先打包了authentication的业务包。先点compile,然后再点install。

        

        成功后,在本地仓库里会生成authentication的jar。

        

        同样的,把所有web依赖的模块都打成jar。

      

      

三、项目整体打包

        最后,项目整体打包。需要操作最外层的根节点。会在target目录下按照build的配置,生成我们想要的包。上传Linux服务器就好能访问了。

       

        

发布了315 篇原创文章 · 获赞 243 · 访问量 26万+

猜你喜欢

转载自blog.csdn.net/yanluandai1985/article/details/104018227