gpt4 book ai didi

java - 在 Spring ApplicationContext.xml 中推送 Maven 属性

转载 作者:搜寻专家 更新时间:2023-11-01 03:19:30 25 4
gpt4 key购买 nike

我想按如下方式将 project.version 从 maven 推送到 appicationContext.xml,

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

在pom.xml中,我配置了maven filter如下

<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

最佳答案

那是因为您将 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>

这样它就会如你所愿地工作。

关于java - 在 Spring ApplicationContext.xml 中推送 Maven 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34766711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com