1.在pom.xml文件中packaging便签下 jar 改为 war
1
|
<packaging>war</packaging> |
2.在pom.xml文件中添加新的依赖包
1
2
3
4
|
<dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-tomcat</artifactid> <scope>provided</scope> </dependency> |
3.在spring-boot启动类的目录下添加一个新的启动类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package com.erxi.ms; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration; import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.boot.web.support.springbootservletinitializer; @springbootapplication (exclude = { datasourceautoconfiguration. class }) public class springbootstartapplication extends springbootservletinitializer { @override protected springapplicationbuilder configure( springapplicationbuilder builder) { // 注意这里要指向原先用main方法执行的mainapplication启动类 return builder.sources(mainapplication. class ); } } |
总结
以上所述是小编给大家介绍的springboot部署在tomcat容器中运行的部署方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:https://blog.csdn.net/sinat_33596545/article/details/83058468