Java 未找到依赖项:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注解:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26095881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
提问by user2659694
I am trying to write a SOAP service using Spring, however I receive a Dependency Injection issue. I'm having problems using @Autowired
through the Service like this:
我正在尝试使用 Spring 编写一个 SOAP 服务,但是我收到了一个依赖注入问题。我在@Autowired
通过服务使用时遇到问题,如下所示:
public interface UserDao {
User getUser(String username);
}
Implementation for Dao as below:
Dao的实现如下:
@Controller("userDao")
public class UserDaoImpl implements UserDao {
private static Log log = LogFactory.getLog(UserDaoImpl.class);
@Autowired
@Qualifier("sessionFactory")
private LocalSessionFactoryBean sessionFactory;
@Override
public User getUser(String username) {
Session session = sessionFactory.getObject().openSession();
// Criteria query = session.createCriteria(Student.class);
Query query = session
.createQuery("from User where username = :username");
query.setParameter("username", username);
try {
System.out.println("\n Load Student by ID query is running...");
/*
* query.add(Restrictions.like("id", "%" + id + "%",
* MatchMode.ANYWHERE)); return (Student) query.list();
*/
return (User) query.uniqueResult();
} catch (Exception e) {
// TODO: handle exception
log.info(e.toString());
} finally {
session.close();
}
return null;
}
}
and
和
public interface UserBo {
User loadUser(String username);
}
and
和
public class UserBoImpl implements UserBo {
@Autowired
private UserDao userDao;
@Override
public User loadUser(String username) {
// TODO Auto-generated method stub
return userDao.getUser(username);
}
}
@WebService
@Component
public class UserService {
@Autowired
private UserBo userBo;
@WebMethod(operationName = "say")
public String sayHello(String name) {
return ("Hello Java to " + name);
}
@WebMethod(operationName = "getUser")
public User getUser(String username) {
return userBo.loadUser(username);
}
}
The below is xml mapping file
下面是xml映射文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://jax-ws.dev.java.net/spring/core
http://jax-ws.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet
http://jax-ws.java.net/spring/servlet.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:annotation-config />
<context:component-scan base-package="edu.java.spring.ws"></context:component-scan>
<context:component-scan base-package="edu.java.spring.ws.dao"></context:component-scan>
<bean id="userDao" class="edu.java.spring.ws.dao.UserDaoImpl"></bean>
<!-- <context:component-scan base-package="edu.java.spring.ws.bo"></context:component-scan>
-->
<wss:binding url="/user">
<wss:service>
<ws:service bean="#userService" />
</wss:service>
</wss:binding>
<bean id="userBo" class="edu.java.spring.ws.bo.impl.UserBoImpl"></bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/contentdb" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="packagesToScan" value="edu.java.spring.ws.model" />
</bean>
</beans>
And the error thrown when deploying is: Here is the updated stack trace:
部署时抛出的错误是:这是更新的堆栈跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean '(inner bean)#538071ba' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:276)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 51 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] 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.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 53 more
回答by Nilesh
You seems to be missing implementation for interface UserDao. If you look at the exception closely it says
您似乎缺少接口 UserDao 的实现。如果您仔细查看异常,它会说
No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency:
找不到类型为 [edu.java.spring.ws.dao.UserDao] 的合格 bean 依赖项:
The way @Autowired
works is that it would automatically look for implementation of a dependency you inject via an interface. In this case since there is no valid implementation of interface UserDao you get the error.Ensure you have a valid implementation for this class and your error should go.
工作的方式@Autowired
是它会自动查找您通过接口注入的依赖项的实现。在这种情况下,因为接口 UserDao 没有有效的实现,你会得到错误。确保你有这个类的有效实现,你的错误应该消失。
Hope that helps.
希望有帮助。
回答by Jens
Add the annotation @Repository
to the implementation of UserDaoImpl
将注解添加@Repository
到实现UserDaoImpl
@Repository
public class UserDaoImpl implements UserDao {
private static Log log = LogFactory.getLog(UserDaoImpl.class);
@Autowired
@Qualifier("sessionFactory")
private LocalSessionFactoryBean sessionFactory;
//...
}
回答by diegomtassis
Look at the exception:
看一下异常:
No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency
This means that there's no bean available to fulfill that dependency. Yes, you have an implementation of the interface, but you haven't created a bean for that implementation. You have two options:
这意味着没有可用于满足该依赖性的 bean。是的,您有接口的实现,但是您还没有为该实现创建 bean。您有两个选择:
- Annotate
UserDaoImpl
with@Component
or@Repository
, and let the component scan do the work for you, exactly as you have done withUserService
. - Add the bean manually to your xml file, the same you have done with
UserBoImpl
.
UserDaoImpl
使用@Component
或 进行注释@Repository
,让组件扫描为您完成工作,就像您使用 所做的一样UserService
。- 手动将 bean 添加到您的 xml 文件中,与您对
UserBoImpl
.
Remember that if you create the bean explicitly you need to put the definition before the component scan. In this case the order is important.
请记住,如果您显式创建 bean,则需要在组件扫描之前放置定义。在这种情况下,顺序很重要。
回答by user2659694
I missed to add
我错过了添加
@Controller("userBo") into UserBoImpl class.
The solution for this is adding this controller into Impl class.
解决方案是将此控制器添加到 Impl 类中。
回答by Kumar Gaurav Sharma
Add repository annotation before your DAO Implementation Class. example:
在您的 DAO 实现类之前添加存储库注释。例子:
@Repository
public class EmpDAOImpl extends BaseNamedParameterJdbcDaoSupportUAM
implements EmpDAO{
}
回答by Georgi Georgiev
I added @Service
before impl class and the error is gone.
我@Service
在 impl 类之前添加,错误消失了。
@Service
public class FCSPAnalysisImpl implements FCSPAnalysis
{}
回答by Jitendra Nandre
We face this issue but had different reason, here is the reason:
我们面临这个问题,但有不同的原因,原因如下:
In our project found multiple bean entry with same bean name. 1 in applicationcontext.xml & 1 in dispatcherServlet.xml
在我们的项目中发现了多个具有相同 bean 名称的 bean 条目。1 在 applicationcontext.xml & 1 在 dispatcherServlet.xml
Example:
例子:
<bean name="dataService" class="com.app.DataServiceImpl">
<bean name="dataService" class="com.app.DataServiceController">
& we are trying to autowired by dataService name.
& 我们正在尝试通过 dataService 名称自动装配。
Solution:we changed the bean name & its solved.
解决方案:我们更改了 bean 名称并解决了。
回答by OAM
In my case I had to move the @Service
annotation from the interface to the implementation class.
就我而言,我不得不将@Service
注释从接口移到实现类。
回答by WesternGun
In my case, the application context is not loaded because I add @DataJpaTest
annotation. When I change it to @SpringBootTest
it works.
就我而言,应用程序上下文未加载,因为我添加了@DataJpaTest
注释。当我将其更改为@SpringBootTest
它时。
@DataJpaTest
only loads the JPA part of a Spring Boot application. In the JavaDoc:
@DataJpaTest
只加载 Spring Boot 应用程序的 JPA 部分。在 JavaDoc 中:
Annotation that can be used in combination with
@RunWith(SpringRunner.class)
for a typical JPA test. Can be used when a test focuses onlyon JPA components. Using this annotation will disable full auto-configuration and instead apply only configuration relevant to JPA tests.By default, tests annotated with
@DataJpaTest
will use an embedded in-memory database (replacing any explicit or usually auto-configured DataSource). The@AutoConfigureTestDatabase
annotation can be used to override these settings. If you are looking to load your full application configuration, but use an embedded database, you should consider@SpringBootTest
combined with@AutoConfigureTestDatabase
rather than this annotation.
可与
@RunWith(SpringRunner.class)
典型 JPA 测试结合使用的注释。当测试仅关注 JPA 组件时可以使用。使用此注释将禁用完全自动配置,而是仅应用与 JPA 测试相关的配置。默认情况下,带有注释的测试
@DataJpaTest
将使用嵌入式内存数据库(替换任何显式或通常自动配置的数据源)。该@AutoConfigureTestDatabase
注释可以用来覆盖这些设置。如果您希望加载完整的应用程序配置,但使用嵌入式数据库,则应考虑@SpringBootTest
结合使用@AutoConfigureTestDatabase
而不是此注释。
回答by kris
Could me multiple reason for this. But you want might forget to add as @Bean for component which you have did @Autowired.
我能不能有多种原因。但是您可能会忘记为您已经使用@Autowired 的组件添加@Bean。
In my case, i have forgot to decorate with @Bean which causing this issue.
就我而言,我忘记用导致此问题的 @Bean 进行装饰。