3

我正在构建一个 Maven 原型。文件名替换工作正常。例如,我有一个名为__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 文件中的令牌 ${artifactId} 永远不会被替换。我的原型-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 文件位于 src/main/resources 下,并且由于 fileSet 设置为过滤,它应该被速度替换,对吗?

有任何想法吗?

4

2 回答 2

0

Have you tried using ${project.artifactId}? According to the Maven Reference Book, all project properties have the project prefix.

于 2012-08-16T20:34:41.013 回答
0

Well, I was changing the template project I've used from mvn archetype:create-from-project instead of the generated-resources that's the reason.

So I ended having VLT doubled escaped.

Fixed :D

于 2012-08-16T21:28:38.450 回答