我可以使用从property-placeholder加载的属性来使上下文导入动态吗?
<context:property-placeholder location="classpath*:/enterprise.properties"/>
<import resource="classpath*:/Fsb${jdbc.ctxType?:Jdbc}-context.xml"/>
属性文件
jdbc.ctxType=JTA
所以这样我就可以改变基于属性加载的上下文文件的类型。
另外,我可以做同样的事情来使bean引用名称动态吗?
<bean id="personBusinessService" class="com.foo.PersonBusinessServiceImpl"
p:personUidDataService-ref="personUidDataService${personUidDataService.sib?:Api}"
p:identifierLookupSearchService-ref="identifierLookupSearchService${identifierLookupSearchService.sib?:Api}"
p:contactPointBusinessService-ref="contactPointBusinessService${contactPointBusinessService.sib?:Api}"
/>
属性文件
personUidDataService.sib=Stub
松鸦
--------------------更新ref的属性示例------------------------ -
我使用以下条目创建了一个属性文件:
addressLookupSearchService.sib=DaoMock
然后我在Spring上下文文件中有以下配置:
<context:property-placeholder location="classpath*:/simple.properties"/>
<!-- EntityManager will be injected into DAO by JPA annotations -->
<bean id="addressSearchDao" class="com.foo.AddressSearchDaoImpl"/>
<bean id="addressSearchDaoMock" class="com.foo.MockAddressSearchDaoImpl"/>
<bean id="addressLookupSearchService" class="com.foo.AddressLookupSearchServiceImpl"
p:baseDao-ref="addressSearch${addressLookupSearchService.sib?:Dao}"/>
并且addressSearch $ {addressLookupSearchService.sib?:Dao}不起作用,它总是默认为 即使我的属性说它应该设置为addressSearchDaoMock,addressSearchDao的bean id。
关于我做错了什么的任何想法?