idea maven多模块springboot打war包

项目结构

在这里插入图片描述
父模块pom文件引入build内容

 <!--指定使用maven打包-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
            <!--maven打包排除spring-boot内嵌tomcat容器依赖jar-->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <!--打包后的名称-->
                    <warName>qb-api</warName>
                    <packagingExcludes>
                        WEB-INF/lib/tomcat-embed-*.jar,
                        WEB-INF/lib/spring-boot-starter-tomcat-*.jar
                    </packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

设置启动类

主模块【springboot主启动类所在模块】
主启动类继承SpringBootServletInitializer,指定启动类
在这里插入图片描述
启动类所在模块pom文件设置打包方式

<packaging>war</packaging>

使用idea maven工具打包,去到父模块maven下执行package
在这里插入图片描述
执行后打包成功
在这里插入图片描述
在这里插入图片描述
到tomcat中执行
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41995299/article/details/116706413