如何使用 Maven Archetype 在 application.properties 中编写属性

How to write properties in application.properties using Maven Archetype

我正在创建一个原型,以便我的团队可以生成几个项目,但我 运行 遇到了问题。

我正在尝试将 属性 写入我的 application.properties 文件,但我似乎无法让它工作。我现在拥有的是:

application.name=my-app-name <--- this should take the artifactId name
logging.file=logback-spring.xml

我试过使用 ${artifactId} 但它没有用。有没有简单的方法来做到这一点?

谢谢!

编辑:编辑仅关注主要目标。

如果 ${artifactId} 不起作用,可能是您的原型没有为资源激活过滤,您可以激活它,将以下配置添加到您的 archetype-metadata.xml

<archetype-descriptor>
  <fileSets>
    ...
    <fileSet filtered="true" packaged="false" encoding="UTF-8">
        <directory>src/main/resources/</directory>
    </fileSet>
    ...