SpringBoot 部署 war 文件至 tomcat 后出现404错误

解决方法:
新建类 ServletInitializer (名字随便取):

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

@Configuration
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(XiaoMaWebsiteApplication.class);
    }
}

然后重新打包成 war 部署即可。

你可能感兴趣的:(SpringBoot 部署 war 文件至 tomcat 后出现404错误)