2016-01-13 105 views
4

我想从行家推project.version到appicationContext.xml如下,春季推行家财产的applicationContext.xml

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

在pom.xml中,我已经配置Maven的过滤器如下

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

</resources> 

过滤器正常工作,但applicationContext.xml已移至目标目录中的类文件夹。我希望它在WEB-INF目录中。希望有清除缓存的静态资源

动态的applicationContext.xml

配置:使用Spring 3.2.xxx

回答

2

那是因为你要过滤的web资源作为一个正常的资源,而这种资源被复制到类路径中。

,你要正确地过滤网络资源,减少您的<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> 

这样,只要你想它会工作。

+0

嗨@malaguna,它不适合我,过滤不适用于appilcationContext.xml。有没有其他配置,我错过了。有没有其他方法可以将maven中的project.version配置为applicationContext.xml – dextermini

+0

让我查看一些细节。你把这个插件放在'' - >''maven部分下吗? 'applicationContext'的路径是否正确? – malaguna

+0

是的,我把它放在buid-> plugins maven部分。路径也是正确的。但有些如何它不适合我。所以尝试了java配置它的方式 – dextermini