今天就跟大家聊聊有关怎么在Centos中使用Tomcat 部署SpringBoot的war包,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。准备war包一、准备好已有的springBo
今天就跟大家聊聊有关怎么在Centos中使用Tomcat 部署SpringBoot的war包,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
1)设置打包格式为war
<packaging>war</packaging>
2)排除SpringBoot内嵌的tomcat
<!-- 以war包部署的形式需要排除内嵌的tomcat --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version></dependency>
3)配置插件
由原来的
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-Maven-plugin</artifactId></plugin></plugins></build>
配置成
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><fork>true</fork><!-- 增加JVM参数 --><jvmArguments>Dfile.encoding=UTF-8</jvmArguments><!-- 指定入口类 --><mainClass>com.peko.filemanager.Application</mainClass></configuration></plugin></plugins></build>
由原来的
@SpringBootApplicationpublic class Application{ public static void main(String[] args) {SpringApplication.run(Application.class, args);}}
配置成
@SpringBootApplicationpublic class Application extends SpringBootServletInitializer { public static void main(String[] args) {SpringApplication.run(Application.class, args);} @Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder builder){return builder.sources(Application.class);}}
先clean一下,再package
成功之后即可在target文件夹里找到打包好的war包
复制出来,然后可以改名字,这里我改成了helloworld.war
https://blog.csdn.net/piano_diano/article/details/116938060
重启tomcat
systemctl restart tomcat
然后打开tomcat的管理界面
可以看到项目处于启动状态,如果是处于关闭状态,就去看tomcat/logs下的日志,报了什么错
注意:如果是以war部署在tomcat中,那么原本我们在yml文件中配置的端口号等信息是作废的
看完上述内容,你们对怎么在centos中使用tomcat 部署SpringBoot的war包有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注编程网精选频道,感谢大家的支持。
--结束END--
本文标题: 怎么在centos中使用tomcat 部署SpringBoot的war包
本文链接: https://www.lsjlt.com/news/277162.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0