解决:org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next tokenfound character ‘@‘

SpringBoot配置多环境时项目启动报错org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '@' that cannot start any token. (Do not use @ for indentation)

方法一:

在pom.xml中增加如下配置:

        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/application.yml</include>
                    <include>**/application-${profiles.active}.yml</include>
                </includes>
            </resource>
        </resources>

如果还是报错不能识别'@',方法二:

如果没有写includes或者是<include>**/*.*</include>可以忽略

不是的话注意${},这里的内容要和properties里面<profiles.active> 这个标签名一样,而且${}里面的内容要和applicaiton.yml配置的spring.profiles.active的值@内容一致:

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profiles.active>prod</profiles.active>
            </properties>
        </profile>
    </profiles>

如果pom.xml写的是这种:<profilesActive>环境</profilesActive>

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profilesActive>dev</profilesActive>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <profilesActive>prod</profilesActive>
            </properties>
        </profile>
    </profiles>

那在主配置文件中就得改成profilesActive,就是要对应。

如果还是报错不能识别'@'符合,在启动前重新拉一下项目依赖。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学编程的曉白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值