springboot打包war部署至tomcat
2017-11-21 16:26
831 查看
参考文章在这里
1、把pom.xml文件中打包结果由jar改成war:
2、排除org.springframework.boot依赖中的tomcat内置容器
1、把pom.xml文件中打包结果由jar改成war:
<modelVersion>4.0.0</modelVersion> <groupId>spring-boot-panminlan-mybatis-test</groupId> <artifactId>mybatis-test</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version>
2、排除org.springframework.boot依赖中的tomcat内置容器
<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>3、添加对servlet API的依赖
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency>4、继承SpringBootServletInitializer ,并覆盖它的 configure 方法,如果我们构建的是war包并部署到外部tomcat则需要使用它,如果使用内置servlet容器则不需要,外置tomcat环境的配置需要这个类的configure方法来指定初始化资源。
@SpringBootApplication public class GuideserverApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(GuideserverApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(GuideserverApplication.class); } }
相关文章推荐
- SpringBoot之打包成war包部署到tomcat
- [置顶] 一步一步学springboot (五)打包成标准的web工程war包可独立部署到tomcat或weblogic
- Springboot项目打包成war包,并在tomcat下部署
- idea中的springboot项目打包成war包部署到tomcat中
- 通过eclipse把spring boot项目打包成war包并部署到tomcat服务器上的步骤
- SpringBoot 打包成war包,部署到tomcat
- SpringBoot之打包成war包部署到tomcat
- (spring boot)maven 打包war 部署到tomcat
- springboot应用war包部署tomcat
- spring boot项目相关配置用war包部署到tomcat下详细教程
- springboot 学习之路 5(打成war包部署tomcat)
- 将Spring Boot应用打包成可部署的War文件
- springboot打包war,tomcat运行及常见问题
- spring boot 学习之路5(打成war包部署tomcat)
- springboot项目打成war包部署到tomcat遇到的一些问题
- 将springboot打包部署到服务器(Tomcat)上
- spring boot项目打包成war并在tomcat上运行的步骤
- 如何将Spring Boot项目打包部署到外部Tomcat
- spring boot打包成war包部署时报404
- 【spring boot】6.idea下springboot打包成jar包和war包,并且可以在外部tomcat下运行访问到