项目部署在linux访问接口404,关于springboot项目部署linux环境的tomcat接口访问404的问题...

先说说可能引起这个问题的原因

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;

}

具体原因这里不深究。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值