gpt4 book ai didi

Maven 原型(prototype) : String replacement not working

转载 作者:行者123 更新时间:2023-12-05 01:11:11 27 4
gpt4 key购买 nike

我正在构建一个 Maven 原型(prototype)。文件名替换工作正常。例如,我有一个名为 __artifactd__-log4j.xml 的文件,生成时可以很好地替换它。但是,其中一个 xml 文件,一个引用它的 spring 上下文文件,它没有被替换:

<?xml version="1.0" encoding="UTF-8"?>

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">



<context:annotation-config />


<bean id="log4jConfigurer" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer"></property>
<property name="targetMethod" value="initLogging"></property>
<property name="arguments">
<list>
<value>classpath:${artifactId}-log4j.xml</value>
<value>5000</value>
</list>
</property>
</bean>

出于某种原因,xml 文件中的 token ${artifactId} 永远不会被替换。我的 archetype-metadata.xml

 <modules>
<module id="${rootArtifactId}-services" dir="__rootArtifactId__-services" name="${rootArtifactId}-services">
<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/webapp</directory>
<includes>
<include>**/*.jsp</include>
<include>**/*.xml</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</fileSet>
</fileSets>
</module>

spring-file 位于 src/main/resources 下,并且由于 fileSet 设置为 filtered 它应该被 velocity 替换,对吗?

有什么想法吗?

最佳答案

您是否尝试过使用 ${project.artifactId}?根据Maven Reference Book ,所有项目属性都有 project 前缀。

关于Maven 原型(prototype) : String replacement not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11994110/

27 4 0