Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring ApplicationContext.xml中推送maven属性_Java_Spring_Maven - Fatal编程技术网

Java 在Spring ApplicationContext.xml中推送maven属性

Java 在Spring ApplicationContext.xml中推送maven属性,java,spring,maven,Java,Spring,Maven,我想将project.version从maven推送到appingContext.xml,如下所示 <mvc:resources mapping="/static/${project.version}/**" location="/static/"/> 在pom.xml中,我配置了maven过滤器,如下所示 <resources> <resource> <directory>${base

我想将project.version从maven推送到appingContext.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>

${basedir}/src/main/webapp/WEB-INF
真的
**/applicationContext.xml
筛选器工作正常,但applicationContext.xml已移动到目标目录中的类文件夹。我希望它位于WEB-INF目录中。想要动态applicationContext.xml来破坏静态资源的缓存吗


配置:使用Spring3.2.xxx

,这是因为您将web资源作为普通资源进行筛选,并且这些资源将复制到类路径

要根据需要正确筛选web资源,请删除
部分,然后尝试以下操作:

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

org.apache.maven.plugins
maven战争插件
2.4
真的
src/main/webapp
WEB-INF/applicationContext.xml

通过这种方式,它将按照您的意愿工作。

Hi@malaguna,它对我不起作用,过滤未应用于appilcationContext.xml。是否有其他配置,我错过了。是否有其他方法可以在maven中将project.version配置为applicationContext.xml让我检查一些详细信息。您是否将此插件置于
->
maven部分?
applicationContext
的路径正确吗?是的,我把它放在buid->plugins maven部分。路径也是正确的。但有些人认为这对我不起作用。所以尝试了java的配置方式