Announcement Announcement Module
Collapse
No announcement yet.
Loading classpath resources and setting file path in Bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading classpath resources and setting file path in Bean

    I have an integration test that needs to get the file path of a properties file in the project and inject it into a bean. The location of the properties file is /src/test/resources/foo.properties in the project and I need someway in the application context to inject it like this:

    Code:
    <bean id="config" class="com.foo.rest.data.Config">
         <property name="fileLocation" value="file location of internal project resource" />
    </bean>
    If anyone can help it would be much appreciated. Thanks.

    Solved it.

    Code:
    <bean id="classLoader" class="java.security.SecureClassLoader" />
    <bean id="config" class="com.foo.rest.data.Config">
            <property name="fileLocation" value="#{classLoader.getResource('foo.properties').getPath()}" />
    </bean>
    Last edited by ColinMc; Jan 7th, 2013, 12:01 PM. Reason: Solved the problem
Working...
X