SpringBoot 打包

1、jarjava

一、pom.xmlweb

<packaging>jar</packaging>

二、mvn命令行打包jarspring

      mvn clean install -Dmaven.test.skip=truetomcat

三、運行app

      java -jar 包名.jarwebapp

 

2、warmaven

一、pom.xmlide

<packaging>war</packaging>

二、排除內置的Tomcat容器spring-boot

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

三、修改啓動類ui

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

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

四、mvn命令打包war

      mvn clean package -Dmaven.test.skip=true

五、運行

war包放到tomcat的webapps目錄下,啓動tomcat,便可。

六、查看

http://localhost:[端口號]/[打包項目名]/

相關文章
相關標籤/搜索