Spring,基于Java配置bean出现 org.springframework.beans.factory.NoSuchBeanDefinitionException

博客讲述了在使用Spring进行基于Java配置时遇到的NoSuchBeanDefinitionException问题,具体表现为无法找到指定类型的bean。问题出现在启动应用程序上下文时。解决方案包括将相关类放在同一包或子包下,或者在配置中正确扫描包含bean的包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前段时间刚接触spring出现了这个问题
十二月 02, 2019 2:06:00 下午 org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@11d72ca: startup date [Mon Dec 02 14:06:00 CST 2019]; root of context hierarchy
Exception in thread “main” org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘net.zhongraun.service.UserService’ available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:353)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at net.zhongruan.springboot_anuto.App.main(App.java:20)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值