检索 spring-批处理作业 bean 定义
Retrieve spring-batch job bean definitions
有没有办法检索在此位置声明的作业 bean:classpath*/META-INF/spring/batch/jobs/*.xml ?
尝试了下面的代码,但我无法检索它们。
@Autowired
private ApplicationContext applicationContext;
public void sometMethod() {
AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();
}
我能够通过以下更改合并 applicationContext 和作业 bean 定义:
@Autowired
private ApplicationContext applicationContext;
public void sometMethod() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"classpath:META-INF/spring/batch/jobs/*.xml"}, applicationContext);
AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();
}
有没有办法检索在此位置声明的作业 bean:classpath*/META-INF/spring/batch/jobs/*.xml ?
尝试了下面的代码,但我无法检索它们。
@Autowired
private ApplicationContext applicationContext;
public void sometMethod() {
AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();
}
我能够通过以下更改合并 applicationContext 和作业 bean 定义:
@Autowired
private ApplicationContext applicationContext;
public void sometMethod() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"classpath:META-INF/spring/batch/jobs/*.xml"}, applicationContext);
AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
String[] strings = ((BeanDefinitionRegistry) beanFactory).getBeanDefinitionNames();
}