Spring 引导父阻止 resources:resources

Spring boot parent prevents resources:resources

我有一个 spring boot maven 项目和一个 属性 文件,我需要在其中替换 spring.cloud.config.server.git.usernamespring.cloud.config.server.git.password 属性的 属性 值使用 mvn resources:resources,但值没有像我预期的那样被替换。 为了找出原因,我创建了一个仅包含 属性 文件和 pom.xml:

的小项目
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>demo</groupId>
    <artifactId>resource-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>resource-demo</name>

    <properties>
        <java.version>1.8</java.version>
        <a.name>placholder</a.name>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>

用上面的 pom 执行 mvn resources:resources -Da.name="some name"${a.name} 没有被替换,但是当我从 pom 中删除 spring 引导父级时,${a.name} 被替换.

谁能解释一下我做错了什么?

这是 属性 文件的内容:

Hello ${a.name}.

documentation 中声明您必须使用 @a.name@ 而不是 ${a.name}