spring boot war 部署
<packaging>jar</packaging>
改成
<packaging>war</packaging>
添加新的依赖<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<build>
<outputDirectory>target/classes</outputDirectory>
<finalName>项目访问名称</finalName>
.....
</build>
@Configuration//配置控制
@EnableAutoConfiguration//启用自动配置
@EnableAsync
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ComponentScan({ "com.test" })
public class Application extends SpringBootServletInitializer {
private static Class<Application> applicationClass = Application.class;
/*
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
@Bean
public Filter initializeHttpPutHandler() {
return new HttpPutFormContentFilter();
}
@Bean
public CharacterEncodingFilter initializeCharacterEncodingFilter() {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
return filter;
}
}
至此可以将项目打包成war发布到tomcat,或者在eclipse用tomcat插件调试了.
http://blog.163.com/gibby_l/blog/static/8300316120162110245135/
推荐阅读
-
详解使用spring boot admin监控spring cloud应用程序
-
详解如何在Spring Boot项目使用参数校验
-
Spring Boot 配置随机数的技巧代码详解
-
使用Spirng Boot Admin监控Spring Cloud应用项目
-
超详细的Spring Boot入门笔记(总结)
-
详解Spring/Spring boot异步任务编程WebAsyncTask
-
详解Spring boot/Spring 统一错误处理方案的使用
-
详解如何将已有项目改造为Spring Boot项目
-
Spring Boot 配置大全(小结)
-
Spring Boot 实现Restful webservice服务端示例代码