先说说可能引起这个问题的原因
1.接口错误
比如说写错单词(可能不大)
写错大小写(linux是区分大小写的)
2.项目错误
就是说tomcat起来了,但是项目没有加载
项目加载了但是无明显报错信息(这个是要注意的)
3.Tomact的错误
tomcat没有配置java环境
然后说说解决方案
tomcat执行成功但是项目没有加载:
需要在Application启动项里面继承SpringBootServletInitializer类
并重写configure接口
之后大致长这个样
@SpringBootApplication
@MapperScan(basePackages = "com.hw.app.mapper")
@EnableTransactionManagement
public class AppApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AppApplication .class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(AppApplication .class);
}
} 第二个就是无明显报错信息,这个就要注意了,只要tomcat启动成功并且确定加载了项目(也就是说springboot的那个logo也出来了)
这时候要注意日志中是否有error这样的打印日志,因为tomcat默认的日志安全级别是比较高的,所以有些日志就不显示
这时候需要在你的resources目录下创建logging.properties文件,内容如下
handlers= org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
org.apache.juli.FileHandler.level= FINEorg.apache.juli.FileHandler.directory= ../logsorg.apache.juli.FileHandler.prefix= error-debug.
java.util.logging.ConsoleHandler.level= FINEjava.util.logging.ConsoleHandler.formatter= java.util.logging.SimpleFormatter再次启动看是否有报错信息,然后根据报错信息解决问题。
其他方案建议百度 因为本人就在这个地方错的其他没经历过不太了解
本人报错
十二月 23, 2020 5:32:43 下午 org.apache.catalina.core.StandardContext filterStart
严重: 启动过滤器异常
javax.naming.NameNotFoundException: Name [com.xx.xx.common.filterandhadler.JwtAuthenticationTokenFilter/jwtUtils] is not bound in this Context. Unable to find [com.xx.xx.common.filterandhadler.JwtAuthenticationTokenFilter].他是说没有绑定上下文,就去看了看自己的写法@Resourceprivate finalJwtUtilsjwtUtils;
是这样的
换成这样
private finalJwtUtilsjwtUtils;
publicJwtAuthenticationTokenFilter(JwtUtilsjwtUtils) {
this.jwtUtils= jwtUtils;
}
具体原因这里不深究。