【问题标题】:How to read application yaml properties from custom maven plugin?如何从自定义 Maven 插件中读取应用程序 yaml 属性?
【发布时间】:2020-03-17 19:25:08
【问题描述】:

如何在自定义 maven 插件中从 application.yaml 读取属性?

文件名不同,可以是application.yaml/yml/properties。

【问题讨论】:

    标签: spring-boot maven-plugin


    【解决方案1】:

    已经有一个插件可以做到这一点:

    <plugin>
        <groupId>it.ozimov</groupId>
        <artifactId>yaml-properties-maven-plugin</artifactId>
        <version>1.1.3</version>
        <executions>
            <execution>
                <phase>initialize</phase>
                <goals>
                    <goal>read-project-properties</goal>
                </goals>
                <configuration>
                    <files>
                        <file>src/main/resources/application.yml</file>
                    </files>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    从那时起,您可以在 pom 本身中使用任何 application.yml 属性,如下所示:

    ${spring.datasource.url}${spring.datasource.password}

    【讨论】:

      猜你喜欢
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      相关资源
      最近更新 更多