*************************** APPLICATION FAILED TO START ***************************
Description:
Field userRepository in com.Lex.Exercise.Service.RegistrationService required a bean of type 'com.Lex.Exercise.Repository.UserRepository' 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.Lex.Exercise.Repository.UserRepository' in your configuration.
// UserRepository
package com.Lex.Exercise.Repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.Lex.Exercise.Model.UserEntity;
public interface UserRepository extends JpaRepository<UserEntity, String>{
}
// RegistrationService
@ComponentScan(basePackages = "com.Lex.Exercise.Repository")
@Component
public class RegistrationService {
@Autowired
private UserRepository userRepository;
//business methods and other validations comes here
}
Это основной класс
package com.Lex.Exercise.SpringBootDemo;
@SpringBootApplication
@PropertySource(value = { "classpath:configuration.properties" })
public class SpringBootDemoApplication implements CommandLineRunner {
@Autowired
private RegistrationService service;
public static void main(String[] args) {
SpringApplication.run(SpringBootDemoApplication.class, args);
}
}
Ниже приведена структура проекта: /SpringBootDemo/src/main/java/com/Lex/Exercise/Model/User.java / SpringBootDemo / src / main / java / com / Lex / Exercise / Model / UserEntity. java /SpringBootDemo/src/main/java/com/Lex/Exercise/Repository/UserRepository.java /SpringBootDemo/src/main/java/com/Lex/Exercise/Service/RegistrationService.java / SpringBot src / main / java / com / Lex / Exercise / SpringBootDemo / SpringBootDemoApplication. java /SpringBootDemo/src/main/resources/application.properties /SpringBootDemo/src/main/resources/configuration.properties*1014 1016 * Пожалуйста, помогите мне, как я мог решить эту проблему