springboot:tomcat启动
程序员文章站
2022-06-16 08:05:16
...
1.在pom.xml里设置 <packaging>war</packaging>
2.移除tomcat插件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
3.添加servlet-api依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
4.修改启动类,并重写初始化方法
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
public class SpringBootStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(Application.class);
}
}
5.mvn clean package打包war包部署到tomcat下
2.移除tomcat插件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
3.添加servlet-api依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
4.修改启动类,并重写初始化方法
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
public class SpringBootStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(Application.class);
}
}
5.mvn clean package打包war包部署到tomcat下
上一篇: springboot:task
推荐阅读
-
springboot、mybatisplus框架整合搭建
-
技术-什么时候需要tomcat服务器,什么时候需要自己搭建服务器
-
springboot整合MybatisPlus基本使用
-
[Abp 源码分析] 一、Abp 框架启动流程分析
-
SpringBoot与MybatisPlus1-搭建mybatisplus
-
aix下实现goldengate随os启动而自动启动的脚本
-
VS2010+OpenCV 2.3.0出现“程序无法启动(0xc000000d)”错误的
-
tomcat8运行报nested exception is java.lang.NoClassDefFoundError
-
Intellij IDEA remote tomcat debug with jrebel on linux
-
大话-springboot 自动装配那些事