在我的项目中,有一个主要的maven模块可以将所有内容保存在1 context.xml
我有一个单独的maven模块,我们尝试使用注释(@Component
,@Autowired
),而不是将所有内容填充到1 context.xml
中。
在我创建的课程中
@Component
public class ActiveDirectoryConfigurationStore implements ConfigurationStore<ActiveDirectoryConfiguration> {
....
}
java
中的这个bean看起来像
public class CacheFactory implements FactoryBean<Cache>, DisposableBean {
...
}
我想引用在这个大context.xml
<bean id="usersCacheFactory" class="cache.impl.CacheFactory">
<constructor-arg index="0" value="users"/>
<constructor-arg index="1" value="db"/>
</bean>
如何在usersCacheFactory
课程中使用@Autowired
注释引用此bean ActiveDirectoryConfigurationStore
?
请注意,ActiveDirectoryConfigurationStore
与此bean位于不同的模块中
答案 0 :(得分:0)
您是否尝试过使用@ImportResource?例如。如下
@Component
@ImportResource(value = { "classpath:/com/yourcompany/othermodule/context.xml" })
public class ActiveDirectoryConfigurationStore implements ConfigurationStore<ActiveDirectoryConfiguration> {
@Autowired
@Qualifier(value="usersCacheFactory")
CacheFactory usersCacheFactory;
....
}