Maven原型:字符串替换不起作用

时间:2012-08-16 19:26:46

标签: maven maven-archetype

我正在建立一个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}永远不会被替换。我的 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文件位于src / main / resources下,因为fileSet设置为filter,所以它应该被velocity替换?

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

好吧,我正在改变我从mvn archetype使用的模板项目:create-from-project而不是生成资源,这就是原因。

所以我结束了VLT加倍逃脱。

修正:D

相关问题