ITeye博客

srping 两种配置方式:xml 和javaConfig

feiteyizu · 2015-12-28 12:02 · spring · 编程语言 · Markdown

xml方式传统方式

 

javaConfig 方式为 ben方式配置

 

main启动方式:

xml:

String paths[] = {"spring-context.xml"};

    ApplicationContext ctx = new ClassPathXmlApplicationContext(paths);

javaConfig:

AnnotationConfigApplicationContext  ctx = new AnnotationConfigApplicationContext(AppContext.class);

AppContext.class 为spring 配置ben

 

javaConifg方式 注解:

@Configuration

 

@ImportResource("classpath:/dubbo-*.xml")

javaConfig方式和xml方式可以同时存在 @ImportResource("classpath:/dubbo-*.xml")注解可以再ben中引入xml配置

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。