yml使用@project.artifactId@启动异常

Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
 in 'reader', line 5, column 12:
      appName: @project.artifactId@
               ^

在pom.xml中添加

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <delimiters>@</delimiters>
                <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
        </plugin>
    </plugins>
    <!--必须添加,否则无法动态获取值-->
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

application.yml的配置,要加双引号或单引号

info:
  appName: "@project.artifactId@"
  version: "@project.version@"
  company: 测试项目
  author: linhongwei

 

posted @ 2023-07-04 08:43  残城碎梦  阅读(328)  评论(0编辑  收藏  举报