@Test
public void Test4(){
ApplicationContext context =
new ClassPathXmlApplicationContext("bean6.xml");
Emp emp = context.getBean("emp", Emp.class);
System.out.println(emp);
}
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'emp' is expected to be of type 'com.atguigu.spring5.bean.Emp' but was actually of type 'com.atguigu.spring5.autowire.Emp'
意思是,我们导错了包:
可以看到
import com.atguigu.spring5.bean.Emp;
import com.atguigu.spring5.bean.Orders;
只需要在开头修改导入的包即可:
import com.atguigu.spring5.autowire.Emp;