package com.gdll;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(GdllApplication.class);
}
}
1,初始化类继承SpringBootServletInitialize,使用eclipse会自动生成servletInitializer类并继承
2.代码context-path路径
server:
servlet:
context-path: /gd
port: 8080
在jar包中访问接口前面都需要加/gd,在maven打包成war时,将该war包放置tomcat的webapps目录下,执行startup.bat,访问controller接口会报404错误
3. 解决方法
将/gd换成war包的名称,再次访问应该就不会出错了。建议将war包名称换成gd.war,就能正常使用/访问