springboot配置tomcat报404,springboot项目tomcat部署的方式

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_38070406/article/details/86563781

在springboot项目启动中不同的是

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@ComponentScan(basePackages = {"com.offerking.oktoutiao_admin"})
@MapperScan(basePackages = {"com.offerking.oktoutiao_admin.dao"})
public class OktoutiaoAdminApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(OktoutiaoAdminApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
		return builder.sources(OktoutiaoAdminApplication.class);
	}

}

启动类需要继承SpringbootServletInitializer
并且需要实现configure方法。

在pom.xml中还需要导入配置

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
展开阅读全文

没有更多推荐了,返回首页