2015-12-09 33 views
1

我有一個要求,我必須從我的項目中加載一個包含CQ5連接詳細信息的屬性文件,並將其作爲bean屬性提供給我的maven依賴項中添加的jar。我的項目使用這個罐子來連接到CQ,所以我應該能夠將CQ連接細節作爲bean屬性提供給該項目。 現在我的項目不是基於彈簧的,所以我不能使用PropertyPlaceholderConfigurer,而添加爲Maven依賴項的jar是基於Spring的。不使用PropertyPlaceholderConfigurer加載屬性文件

有沒有其他的方法來替換下面的bean屬性中的值。

<bean id="slingJsonRequestor"  class="com.my.project.content.requestor.SlingRequestor"> 
    <constructor-arg name="suffix" value="json.js"></constructor-arg> 
    <constructor-arg name="resourceBlacklist" ref="slingBlacklistCache"></constructor-arg> 
    <property name="url" value="${cq-url}"></property> 
    <property name="urlCacId" value="${cq-url-cacid}"></property> 
    <property name="urlTemplate" value="${cq-url-template}"></property> 
</bean> 

請提供一個非彈簧解決方案來實現這一點。

+0

如果有任何方法可以實現從EJB3.0應用程序中設置這些屬性,請幫助 – Neel

回答

0

是的,可以用Maven來完成。

Maven Resources Plugin

你根本屬性元素和資源元素添加到您的pom.xml:

<properties> 
    <myproperty>A special value</myproperty> 
</properties> 

<build> 
    <resources> 
     <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     <includes> 
      <include>**/myproperties.properties</include> 
     </inlcudes> 
     </resource> 
    </resources> 
</build> 

這時如果文本$ {myProperty的}在myproperties.properties遇到行家將取代它與pom.xml的屬性值(與Spring不同,嘿?)

相關問題