Pushing maven property in Spring ApplicationContext.xml

I want to click project.version from maven in appicationContext.xml as follows,

<mvc:resources mapping="/static/${project.version}/**" location="/static/"/>

In pom.xml, I configured the maven filter as follows

<resources>
            <resource>
                <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                <filtering>true</filtering>
                <includes>
                  <include>**/applicationContext.xml</include>
                </includes>
            </resource>

</resources>

The filter works correctly, but applicationContext.xml is moved to the class folder in the destination directory. I want this in the WEB-INF directory. Want to have dynamic applicationContext.xml to iterate over cache for static resources

Configuration: using Spring 3.2.xxx

+4
source share
1 answer

This is because you are filtering the web resource as a regular resource, and these resources are copied to the class path.

- , <resources> :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <webResources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/webapp</directory>
                <includes>
                    <include>WEB-INF/applicationContext.xml</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>

, , .

+2

Source: https://habr.com/ru/post/1624096/


All Articles