这篇文章主要介绍SpringBoot中war包如何部署到Tomcat服务器,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
成都创新互联公司专业为企业提供化隆网站建设、化隆做网站、化隆网站设计、化隆网站制作等企业网站建设、网页设计与制作、化隆企业网站模板建站服务,十余年化隆做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
(1)pom.xml文件修改
4.0.0 springboot springboot 0.0.1-SNAPSHOT war springboot Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 1.5.4.RELEASE UTF-8 UTF-8 1.7 org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-logging org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-thymeleaf org.springframework.boot spring-boot-starter-log4j 1.3.8.RELEASE org.springframework.boot spring-boot-starter-data-redis MySQL mysql-connector-java org.mybatis.spring.boot mybatis-spring-boot-starter 1.1.1 springboot org.springframework.boot spring-boot-maven-plugin
(2)修改项目启动类,继承SpringBootServletInitializer,如下:
package springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@EnableCaching
public class SpringbootApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringbootApplication.class);
}
}(3)打包:可以通过eclipse run as ->maven install,也可以进入项目的根目录,也就是pom.xml同一级目录,启动cmd控制台,执行mvn install package,如下:

(4)环境搭建(linux环境JDK安装与Tomacat安装(springboot支持tomcat7以上))
JDK安装参考:https://www.jb51.net/LINUXjishu/66536.html
Tomcat安装参考:https://www.jb51.net/article/95272.htm
(5)将打包好的war包上传至tomcat目录下webapp目录下,启动tomcat服务器。
(6)访问项目路径:http://ip地址:端口号/项目打包名称/方法名(项目打包名称即pom.xml中的
(7)设置tomcat开机自动启动
(1)修改脚本文件rc.local:vim /etc/rc.d/rc.local
(2)在rc.local中增加:export JAVA_HOME = jdk安装路径 ,tomcat安装路径/bin/startup.sh start
以上是“SpringBoot中war包如何部署到Tomcat服务器”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!