我尝试通过使用ClassPathXmlApplicationContext
获得bean。但我收到:NoSuchBeanDefinitionException: No bean named 'newsController' is defined
ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("classpath*:conf/Spring_Config.xml");
NewsController newsController = (NewsController)
applicationContext.getBean("newsController");
在 xml 中:
<bean id="newsController" class="NewsController"/>
答案 0 :(得分:0)
为bean类标记添加完整路径
class = com.foo.NewsController