场景:IDEA打包war项目在tomcat容器中启动,在IDEA中项目正常启动访问,部署到tomcat容器中启动报错:javax.naming.NameNotFoundException: 名称[com.example.desktopserver.security.JwtAuthenticationTokenFilter/tokenService]未在此上下文中绑定。找不到[com.example.desktopserver.security.JwtAuthenticationTokenFilter]。
根据网上回答和报错提示进入到类JwtAuthenticationTokenFilter中排查原因。
原因:由于我在servlet中使用了@Resource注解注入了spring容器中的bean
@Resource
private TokenService tokenService;
本人项目解决错误方式如下:
网上还有说各种方式,具体的解决方案还得根据报错提示来处理。