【问题标题】:Spring boot parent prevents resources:resourcesspring boot parent 防止资源:resources
【发布时间】:2020-03-10 08:11:09
【问题描述】:

我有一个带有属性文件的 spring boot maven 项目,我需要在其中使用 mvn resources:resources 替换 spring.cloud.config.server.git.usernamespring.cloud.config.server.git.password 属性的属性值,但这些值没有按我的预期替换。 为了找到原因,我创建了一个只包含属性文件和 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 boot parent时,${a.name}被替换了。

谁能解释我在这里做错了什么?

这是属性文件的内容:

Hello ${a.name}.

【问题讨论】:

标签: java spring-boot maven maven-resources-plugin


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-07-22
    • 2017-02-05
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 1970-01-01
    • 2016-10-22
    • 2016-07-12
    相关资源
    最近更新 更多