简体   繁体   中英

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)

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM