gpt4 book ai didi

java - 使用 spring-boot 在依赖注入(inject)中创建 bean 时出错

转载 作者:行者123 更新时间:2023-12-02 09:51:39 25 4
gpt4 key购买 nike

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

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

当我尝试将其注入(inject) info.iyngaran.core.auth.security 包中的 CustomUserDetailsS​​ervice 类时,出现以下错误。

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 主类中解决了该问题。

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

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

关于java - 使用 spring-boot 在依赖注入(inject)中创建 bean 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56278879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com