从Groovy Spring配置中的Annotation Spring配置中定义的访问bean

时间:2015-04-20 06:27:26

标签: java spring groovy

我使用GenericGroovyApplicationContext来加载我的groovy和xml弹簧配置。但是我还有一些需要加载的遗留@Configuration类。问题是Groovy配置无法引用@Configuration类中定义的任何bean。这就是我正在做的事情。

GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
ctx.load("classpath:spring/SpringConfig.groovy");
AnnotatedBeanDefinitionReader configReader = new AnnotatedBeanDefinitionReader(ctx);
configReader.register(JavaConfig.class);
ctx.refresh()

我也尝试过使用AnnotationConfigApplicationContext,但同样的问题,在groovy配置中定义的bean不能引用@Configuration类中定义的bean。

我知道Groovy和xml很好地协同工作,但不确定是否支持。有没有工作?

0 个答案:

没有答案
相关问题