这是我的代码-https://github.com/iyngaran/to-do-list

我在info.iyngaran.core.auth.repository包中有UserRepository类,并用@Repository进行了注释。

当我尝试将其注入CustomUserDetailsService包中的info.iyngaran.core.auth.security类中时,出现以下错误。

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customUserDetailsService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'info.iyngaran.core.auth.repository.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


有人可以帮我找出这个问题吗?提前致谢。

最佳答案

我通过在spring boot main类中添加以下行来解决此问题。

@EnableJpaRepositories({"info.iyngaran.core","info.iyngaran.todolistapi"})


那解决了我的问题。这是详细信息-https://stackoverflow.com/a/53172477/9348637

09-12 04:25