# The main class inherits SpringBootServletInitializer and override configure
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@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);
}
}
# Restart the project
# pom.xml
<!--打包成jar包-->
<packaging>jar</packaging>
# To perform the packaging operation, double-click package in the Maven Projects column on the right side of idea and wait for Build Success to appear
# Find the target folder in the project path to open, there are packaged jar packages
— .idea
— .mvn
— src
— target
- .gitignore
— Project name.iml
— HELP.md
- mvnw
— mvnw.cmd
- pom.xml
# Open cmd, cd to the location of .jar, and execute the code:
java -jar 项目名.jar
# Wait for the project to start, visit http://127.0.0.1:[port number]
The server operation can refer to: https://blog.csdn.net/weixin_42863549/article/details/104571580