springboot 项目部署到外部tomcat详解编程语言
2023-06-13 09:20:44 时间
最近在用spring boot 弄了一个学习型的项目,学习一下spring boot怎样构建项目,spring boot 本身是内置tomcat的,如果想部署到外部tomcat, 就要做一些改变。
1 默认打包方式是jar包,改成war包打包,在pom.xml 里
packaging war /packaging
2 在maven里排除自带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
第二种:
dependency groupId org.springframework.boot /groupId artifactId spring-boot-starter-tomcat /artifactId scope provided /scope /dependency
3 将项目的启动类Application.java继承SpringBootServletInitializer并重写configure方法
@SpringBootApplication public class BootdoApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(BootdoApplication.class, args); System.out.println( ヾ(◍°∇°◍)ノ゙ bootdo启动成功 ヾ(◍°∇°◍)ノ゙/n + ______ _ ______ /n + |_ _ // / |_|_ _ `. /n + | |_) | .--. .--. `| |- | | `. // .--. /n + | __ . / . `// /// . `// //| | | | | |/ . `// // /n + _| |__) || //__. || //__. || |, _| |_. /| //__. | /n + |_______/ .__. .__. //__/|______. .__. } protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // 注意这里要指向原先用main方法执行的Application启动类 return builder.sources(BootdoApplication.class); } }
4 在idea 里用maven打包
maven clean and install 就打包完成了,在target下就能找到war包
5 后来发现war包在本地跑没问题,部署到服务器上就无法启动了,查阅spring boot 官方文档发现spring boot 只支持tomcat 8.5 以上版本,而服务器上的版本是7.0.47
需要在pom.xml里指定低版本的tomcat
properties tomcat.version 7.0.47 /tomcat.version /properties
6 将打包好的war 放到tomcat的webapps下面 启动就可以了。
15327.html
cjavaxml相关文章
- Java项目毕业设计:基于springboot+vue的电影视频网站系统「建议收藏」
- SpringBoot的启动流程_springboot启动卡住了
- SpringBoot前后端数据传输加密「建议收藏」
- springboot eclipse 热部署
- Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包
- springboot事物oracle,SpringBoot 事务管理
- 基于SpringBoot使用AOP技术实现操作日志管理[通俗易懂]
- SpringBoot打包成jar之后在Linux执行,然后删除jar,会发生什么?
- java检测tomcat宕机_Tomcat意外宕机分析
- Tomcat之——宕机自动重启和每日定时启动tomcat
- 记一次线上服务器宕机 springboot tomcat
- SpringBoot项目整合Mybatis入门,看这一篇就够了
- idea配置Tomcat_tomcat docbase
- springboot原理详解_Spring Boot
- SpringBoot实战:整合Swagger3实现在线Api文档
- 【SpringBoot技术专题】「实战指南」从实战开发角度去分析操作RestTemplate的应用及使用技巧
- SpringBoot(一)走进Springboot的世界详解编程语言
- 详解js插件ajaxupload实现图片上传(适用springboot)编程语言
- SpringBoot+mybatis实现多数据源支持详解编程语言
- SpringBoot之外部Tomcat运行Spring Boot项目详解编程语言
- Linux系统中使用Tomcat快速配置方法(linux配置tomcat)
- springboot-springcloud-eureka 服务注册与发现,负载均衡客户端(ribbon,feign)调用详解编程语言
- 轻松启动Tomcat:Linux环境的实现(linux怎么启动tomcat)
- Linux下安装Tomcat服务器的步骤(linux上安装tomcat)
- Linux系统下部署高性能Tomcat服务器(linux部署tomcat)
- 以Linux运行Tomcat,实现轻松部署Web应用(linux tomcat)