SSouhaieb
SSouhaieb

Reputation: 238

Alfresco : Access to properties file from java class

I want to know how to access to a properties file that is under share from a java class (under alfresco) which will be exported later as a .jar file under alfresco/lib.

Upvotes: 0

Views: 608

Answers (1)

abarisone
abarisone

Reputation: 3783

As reported in this Alfresco forum post you should register a Spring bean in your context exploiting the PropertyPlaceholderConfigurer, setting the proper location of you properties file will be found.

<bean id="custom-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders">
        <value>true</value>
    </property>
    <property name="locations">
        <list>
            <value>classpath:alfresco/extension/custom.properties</value>
        </list>
    </property>
</bean>

From now on every time you define a bean you can use placeholders taken from the property file, which has a common key=value format.

Upvotes: 1

Related Questions