软件编程
位置:首页>> 软件编程>> java编程>> 配置springboot项目使用外部tomcat过程解析

配置springboot项目使用外部tomcat过程解析

作者:山猫大战响尾蛇  发布时间:2021-11-22 22:34:25 

标签:配置,spring,boot,外部,tomcat

 这篇文章主要介绍了配置springboot项目使用外部tomcat过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

在pom文件中添加依赖


<!--使用自带的tomcat-->
<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-tomcat</artifactId>
 <scope>provided</scope>
</dependency>

在Springboot自带的Application启动类所在目录下新建启动类SpringBootStartApplication


package com.huang;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
//让该类继承springboot的SpringBootServletInitializer
public class SpringBootStartApplication extends SpringBootServletInitializer {
 @Override
 protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
   //找到原先的启动类
   return application.sources(WebchatApplication.class);
 }
}

#目录如下
src
|-main
 |-java
   |-com.huang.sockerservice
   |-WebchatApplication.class #原本的启动类
   |-SpringBootStartApplication.class #新的启动类
 |-resources

来源:https://www.cnblogs.com/Createsequence/p/11335688.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com