打包配置

打包配置

打 jar 包

  • pom.xml
<build>
    <plugins>
    	<plugin>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-maven-plugin</artifactId>
    	</plugin>
    </plugins>
</build>

java -jar xxx.jar 启动

打 war 包

  • pom.xml
    • 修改打包形式
      <packaging>war</packaging>
      
    • <build>标签下构建项目名称
      <finalName>name_your_want</finalName>
      
    • 修改启动类,使其继承 SpringBootServletInitializer
      @SringbootApplication
    	public class MyApplication extends SpringBootServletInitializer {
    
          @Override
          protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
              return application.sources(MyApplication.class);
          }
    
          public static void main(String[] args) throws Exception {
              SpringApplication.run(MyApplication.class, args);
          }
    
      }
    
  • 启动 tomcat, 扔 war 包
posted @ 2019-11-27 14:47  scp-166  阅读(158)  评论(0编辑  收藏  举报