SpringBoot中,yml无法识别@符号

SpringBoot中,yml无法识别@符号

问题:application.yaml文件读取不到pom.xml下的标签值,报
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 7, column 13:
active: @spring.profiles.active@
的解决方法 :
在pom文件中写入以下代码

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

这段代码是用来配置 Maven 项目构建过程中资源文件的处理方式的。具体来说:

  • <directory>src/main/resources</directory> 指定了资源文件的目录为 src/main/resources ,这是 Maven 项目中存放资源文件的默认目录。
  • <filtering>true</filtering> 表示开启资源文件的过滤功能。当设置为 true 时,Maven会在资源文件中查找 ${...} 形式的占位符,并根据项目中的属性值替换这些占位符。这样可以实现动态替换配置文件中的变量值,比如替换版本号、环境变量等。

原文链接:https://blog.youkuaiyun.com/a1513049385/article/details/114280579

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值