Spring配置类替代xml配置文件
文章目录
@Configuration //表示该类是配置类
@ComponentScan(backPackages={"com.zong.spring"}) //表示注解扫描哪个文件
public class SpringConfig{
}
//加载配置文件
ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);@Configuration //表示该类是配置类
@ComponentScan(backPackages={"com.zong.spring"}) //表示注解扫描哪个文件
public class SpringConfig{
}
//加载配置文件
ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论