gpt4 book ai didi

java - 无法自动连接[错误 : No matching bean of type]

转载 作者:太空宇宙 更新时间:2023-11-04 09:30:54 25 4
gpt4 key购买 nike

我尝试部署我的项目,但出现此错误,但未能解决。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'educationUserDetailsBuilder': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metaarchit.education.school.persistence.SemesterDao com.metaarchit.education.framework.security.spring.EducationUserDetailsBuilder.semesterDao; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.metaarchit.education.school.persistence.SemesterDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)

我不知道我应该发布什么内容,如果您需要其他可以提供帮助的内容,请告诉我您需要什么文件。

最佳答案

你在某个地方有一个类SemesterDao吗?您可能在代码中做了类似的事情:

public class MyClass {
@Autowire
private SemesterDao semesterDao;
...

只有当 Spring 知道如何创建它的实例时,这才能正常工作。您可以通过进入您的类并在其上添加一个名为 Component 的注释来实现此目的:

@Component
public class SemesterDao {
}

出于好奇,使用 Spring 时通常也会使用 Spring Data,这样您就可以扩展 JpaRepository 并已经实现了许多有用的方法。您可以在这里进一步查看:https://www.baeldung.com/the-persistence-layer-with-spring-data-jpa

关于java - 无法自动连接[错误 : No matching bean of type],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57107753/

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