Java 多模块下打包部署

2023-02-23  本文已影响0人  iOS虞

模块之间关系如下图所示

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一样

上一篇 下一篇

猜你喜欢

热点阅读