RT 就老是出现找不到bean的样子
//这个是java文件 package com.imooc.beanannotation; import org.springframework.stereotype.Component; @Component public class BeanAnnotation { public void say(String word){ System.out.println("BeanAnnotation:"+word); } } //这个是配置文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:component-scan base-package="com.imooc.beanannotation"> </context:component-scan> </beans> //这个是测试的文件,,我没安装老师那个方法,而是直接实例化 @Test public void TestbeanAnnotation() { ApplicationContext alc=new ClassPathXmlApplicationContext("spring-beanannotation.xml"); BeanAnnotation bean=(BeanAnnotation)alc.getBean("beanAnnotation"); bean.say("fuck"); }