java - 需要一个找不到的“com.ganesh.utils.JwtUtils2”类型的 bean
问题描述
这个错误有很多问题,其中大多数与存储库和服务类有关,但我找不到与我的情况完全相关的问题。
我里面的包结构src/main/java/com/ganesh/
是这样的
├── ApiApplication.java
├── interceptors
│ └── AuthorizationInterceptor.java
└── utils
└── JwtUtils.java
...
JwtUtils
定义如下
@Component
public class JwtUtils {
...
}
并AuthorizationInterceptor
定义为
@Component
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationInterceptor.class);
@Autowired
private JwtUtils jwtUtils;
...
}
主类定义为
@SpringBootApplication
public class ApiApplication {
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}
当我运行我得到这个错误。
***************************
APPLICATION FAILED TO START
***************************
Description:
Field jwtUtils in com.ganesh.interceptors.AuthorizationInterceptor required a bean of type 'com.ganesh.utils.JwtUtils' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.ganesh.utils.JwtUtils' in your configuration.
我不确定我错过了什么。
解决方案
推荐阅读
- r - 无法将类型“闭包”强制转换为“字符”类型的向量 rgl 包
- database - 如何从 Data Lake Storage Gen 1 将数据导入 Azure SQL 数据库?
- python - 为什么在 Python 中操作另一个列表会影响列表的新副本?
- android - android,如何在应用端生成较短版本的 uuid(13 个字符)
- excel - Finding a more efficient way of using SUM PRODUCT and COUNTIF
- react-native - 通过屏幕堆栈传递道具
- ios - 有没有办法以编程方式更改滚动视图焦点?
- excel - 同时计算 4 个不同的字段:
- identityserver4 - .net core 3.1 Google SSO 回调网址未命中
- html - 在悬停时展开带有动画的按钮