Требуется bean-компонент типа com.gane sh .utils.JwtUtils2, который не может быть найден - PullRequest
1 голос
/ 20 июня 2020

Есть много вопросов по этой ошибке, большинство из них связано с репозиториями и классами обслуживания, но я не смог найти ни одного, относящегося именно к моему случаю.

Моя структура пакета внутри 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.

Я не уверен, что я пропустил.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...