import Test_01.Test02;
import Test_01.Test_03;
import Test_02.Test_05;
(这里要特别注意包是否导进来)
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Created by XiaoBai on 2019/9/25.
*/
public class Test_ZhuLei {
public static void main(String[] args) {
AnnotationConfigApplicationContext ioc = new AnnotationConfigApplicationContext(Test_PeiZh.class);
ShuXin shuXin = (ShuXin) ioc.getBean("shuXin");
Test02 test = ioc.getBean(Test02.class);
System.out.println(shuXin);
System.out.println(test);
Test_03 test_03 = ioc.getBean(Test_03.class);
System.out.println(test_03);
//这里是用的(import Test_02.Test_05;)包的类
Test_05 test05 = ioc.getBean(Test_05.class);
System.out.println(test05);
}
}
```配置类
import org.springframework.beans.factory.annotation.Autowired;
import org.springframe
@ComponentScan自动导入和指定导入
最新推荐文章于 2023-08-08 10:20:00 发布