gpa
gpa

Reputation: 2451

Spring 3.2 resource file loading issue

I have following spring configuration for resource files, it works perfectly well when i execute in eclipse environment. But when i package the application into JAR and execute it does not file properties file resource.

    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="locations">
        <list>
            <value>classpath:Application.properties</value>
            <value>classpath:database.properties</value>
        </list>
    </property>
</bean>

<!-- define the properties file to use -->
<util:properties id="appProperties" location="classpath:Application.properties" />

When i see the jar file all files are present. I am using maven to build assembly.

Project structure:

ProjName | |--main |-- java |-- resources

Also, i am using maven config using this link (http://stackoverflow.com/questions/13615634/maven-build-assembly-with-dependencies)

Upvotes: 1

Views: 471

Answers (1)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136122

There's not enough information at the moment to know exactly what's happening. But In my view there is some confusion in context.xml. To start with, I would suggest to replace all the above with

<context:property-placeholder location="classpath:/Application.properties, classpath:/database.properties" />

Upvotes: 1

Related Questions