1
的同事,我有主類,它看起來像:如何上傳不同的上下文配置類?
public class App {
static final Logger LOG = Logger.getLogger(App.class.getName());
public static void main(String[] args) {
for(int i = 0; i < args.length; i++) {
switch (args[i]) {
case "OrderUpload":
ApplicationContext ctxOrderUpload = new AnnotationConfigApplicationContext(AppConfigBasic.class);
OrderUpload OrderUpload = ctxOrderUpload.getBean(OrderUpload.class);
OrderUpload.process();
break;
case "TrdUpload":
ApplicationContext ctxTrdUpload = new AnnotationConfigApplicationContext(AppConfig.class);
TrdUpload TrdUpload = ctxTrdUpload.getBean(TrdUpload.class);
TrdUpload.process();
break;
default:
LOG.info("Process is not defined - > " + args[i]);
System.exit(0);
}
}
}
而且我有兩個配置類:
@Configuration
@EnableTransactionManagement
@ComponentScan
public class AppConfigBasic {}
和擴展配置
@Configuration
@EnableTransactionManagement
@ComponentScan
public class AppConfig extends AppConfigBasic {}
爲什麼當執行java -jar app.jar OrderUpload
彈簧負載豆來自AppConfig(不僅來自AppConfigBasic`)? 如何在交換機中爲不同情況使用不同的上下文配置文件? 謝謝。