Spring配置类替代xml配置文件

@Configuration //表示该类是配置类
@ComponentScan(backPackages={"com.zong.spring"}) //表示注解扫描哪个文件
public class SpringConfig{
}

//加载配置文件

ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);

评论

暂无评论