你没有告诉你需要什么样的替代品,但是......
对于很多情况,您只需使用常规 Maven 资源插件并打开过滤即可。这样它将取代任何${values}
具有 Maven 运行时属性。
有关插件的文档 http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
对于 .jsps,您可能已经在使用 war 插件。使用 war 插件,它就像这样
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<directory>src/main/resources/WEB-INF</directory>
<includes>
<include>*.jsp</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
然后你的 JSP 中就会有这样的内容:
<script src="${mypath}/test.js"></script>
在 Maven pom 中:
<properties>
<mypath>testpath</mypath>
</properties>
取决于您的项目配置。 (例如,src/main/webapp 也经常被使用)
编辑:您在注释中添加了您有一个计算 md5 的 shell 脚本并且您想要使用它。我不知道这样做的优雅方法,因此建议一种不太优雅的方法:使用 groovy 插件执行脚本并获取属性的值。
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<providerSelection>2.0</providerSelection>
<properties>
<script>path/to/your/shell-script.sh</script>
</properties>
<!-- if the script prints its result to stdout -->
<source>
def command = project.properties.script
def process = command.execute()
process.waitFor()
def result = process.in.text.trim()
project.properties.md5Value = result
</source>
<!-- if the script prints the result to a file -->
<!-- note that you have to define this result file name somewhere -->
<source>
def command = project.properties.script
def process = command.execute()
process.waitFor()
def resultfile = new File(project.properties.result_file)
project.properties.md5Value = resultfile.getText()
</source>
<!-- only use one or the other script block! -->
</configuration>
</execution>
</executions>
</plugin>