org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'studentBean' is defined
但是beanname 我已经定义过来
;
@Test
public void student()
{
ApplicationContext context = new ClassPathXmlApplicationContext(
"classpath*:applicationContext.xml");
Student obj = (Student) context.getBean("studentBean");
System.out.print(obj.getName());
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="studentBean" class="com.frank.springmvc.controller.Student">
<!-- 在这里写额外的bean的配置和相关引用 -->
<property name="name" value="hanyu"></property>
</bean>
<!-- 更多数据访问层的bean定义写在这里 -->
</beans
qq_木偶_2
相关分类