SpringBoot打包成war包

项目结构如下:

SpringBoot打包成war包_第1张图片

将pom文件中的packaging的jar修改为war



	4.0.0
	com.javainuse
	employee-producer
	0.0.1-SNAPSHOT
	war

	
		org.springframework.boot
		spring-boot-starter-parent
		1.4.1.RELEASE
		 
	

	
		UTF-8
		UTF-8
		1.8
	

	
                
		
			org.springframework.boot
			spring-boot-starter-web
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

修改启动类

package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
 
@SpringBootApplication
public class SpringBootHelloWorldApplication  extends SpringBootServletInitializer {
	
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootHelloWorldApplication.class);
    }
 
	public static void main(String[] args) {
		SpringApplication.run(SpringBootHelloWorldApplication.class, args);
	}
}

修改完成之后重新打包

站在巨人的肩膀上摘苹果:

https://www.javainuse.com/spring/boot-war

你可能感兴趣的:(SpringBoot打包成war包)