Upload the springboot project to the cloud server to run war

And modify pom.xml to the following code:

        <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>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>

The packaged file name can be modified here 

New SpringBootStartApplication

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;



 /**
 * 修改启动类,继承 SpringBootServletInitializer 并重写 configure 方法
 */
public class SpringBootStartApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(EarthSiteApplication.class);
    }
}

After you have the packaged war package, you must first use java -jar xxx.war to test on the cloud server. If there is no problem, then there is no problem with the war file under Tomcat.

Put the war package here, Tomcat will automatically decompress and run

Guess you like

Origin blog.csdn.net/weixin_43135178/article/details/111947429