此错误有很多问题,其中大多数与存储库和服务类有关,但我找不到与我的情况相关的一个问题。
我在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.
我不确定我错过了什么。