美文网首页
Java 多模块下打包部署

Java 多模块下打包部署

作者: iOS虞 | 来源:发表于2023-02-23 19:52 被阅读0次

模块之间关系如下图所示

image.png

A: pom中设置<packaging>pom</packaging>
B: pom中设置<packaging>jar</packaging>
C: pom中设置<packaging>war</packaging>

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
</dependency>

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <scope>provided</scope>
</dependency>


<build>
        <finalName>xxxx</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

启动类中

@SpringBootApplication
public class MgrSite extends SpringBootServletInitializer{
    public static void main(String[] args) {
     
        SpringApplication.run(MgrSite.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(MgrSite.class);
    }
}

D: 配置和C一样

相关文章

网友评论

      本文标题:Java 多模块下打包部署

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