Prepare war package1. Prepare the existing SpringBoot project and add dependencies in pom1) Set the packaging format to war <packaging>war</packaging> 2) Exclude the tomcat embedded in SpringBoot <!-- When deploying in war package, you need to exclude the embedded 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) Configure plugin From the original <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> Configure <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <!-- Add jvm parameters --> <jvmArguments>Dfile.encoding=UTF-8</jvmArguments> <!-- Specify the entry class --> <mainClass>com.peko.filemanager.Application</mainClass> </configuration> </plugin> </plugins> </build> 2. Configure the startup classFrom the original @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } Configure @SpringBootApplication public class Application extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(Application.class); } } 3. Packaging with Maven ToolsClean first, then package After success, you can find the packaged war package in the target folder Copy it and then change the name. Here I changed it to helloworld.war Deploy to tomcat on centos1. First, install tomcathttps://blog.csdn.net/piano_diano/article/details/116938060 2. Upload the war package to tomcat/webapps using the sftp toolRestart tomcat
Then open the tomcat management interface You can see that the project is in the startup state. If it is in the shutdown state, go to the log under tomcat/logs to see what error is reported.
helloworld project address: https://gitee.com/ShyHour/hello-world The above is the details of using tomcat to deploy SpringBoot's war package in the centos environment. For more information about tomcat deploying SpringBoot's war package, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Modify the style of HTML body in JS
>>: The concept and characteristics of MySQL custom variables
Basic introduction to robots.txt Robots.txt is a p...
HTML forms are commonly used to collect user info...
Table of contents background LIMIT Optimization O...
I have searched various major websites and tested...
MySQL 5.7.17, now seems to be the latest version,...
CSS 3 animation example - dynamic effect of Tab b...
1. Basic Environment 1. Operating system: CentOS ...
Table of contents Creating HTML Pages Implement t...
Table of contents Preface Initialize the project ...
1: Understand the meaning of address rewriting an...
Table of contents Code: Replenish: Summarize Requ...
Today I suddenly thought of reviewing the producti...
This topic is an internal sharing in the second h...
Before talking about the structural markup of web...
PCIE has four different specifications. Let’s tak...