srping 两种配置方式:xml 和javaConfig

 

 

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配置

猜你喜欢

转载自feiteyizu.iteye.com/blog/2267139
今日推荐