搜索
您的当前位置:首页正文

idea maven多模块springboot打war包

来源:欧得旅游网

项目结构

 <!--指定使用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,指定启动类

<packaging>war</packaging>

使用idea maven工具打包,去到父模块maven下执行package

因篇幅问题不能全部显示,请点此查看更多更全内容

热门图文

Top