Search code examples
javaspringresourcesclassloader

How to access resources in external jar file using spring?


I have a spring project which uses different libraries, packed as multiple jars. One of them (jar) has xml files, as resources.

What I'm trying to do, is to inject this resources to castor marshaller, like here:

<bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller">

    <property name="mappingLocations">
        <list>
            <value>classpath*:/mapping*.xml</value>
        </list>
    </property>

</bean>

It doesn't work, and the array of resources is empty.

What am I doing wrong?


Solution

  • Make it:

    <value>classpath:mapping*.xml</value>
    

    Provided that, mapping*.xml file is there directly on classpath (root of external jar which is directly under classpath)