开发者社区> 问答> 正文

springboot做了基于maven的多环境配置后,idea里面不能启动了,如何解决?报错

application.yaml

spring:
  profiles:
    active: @profileActive@

pom.xml文件中配置profiles节点

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

使用maven命令打包成相应环境的程序包

生产环境

mvn clean package -Pprod

 这些都没有问题,但是在idea里面启动时报错

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 3, column 13:
        active: @profileActive@


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 3, column 13:
        active: @profileActive@

idea是加vm和程序参数都是不行,请问下如果解决这个问题

展开
收起
爱吃鱼的程序员 2020-06-06 20:21:01 2190 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>spring:<br>
    

      profiles:
        active: @profileActive@

    感觉这个是多余的

                                回复 <a class="referer" target="_blank">@Eric_林</a>  : 同样的配置,同事的电脑是完全可以正常运行的,
                        
    
                            这个@是让maven用的,点位符 mvn -P
                        
    
                            @profileActive@   引用有问题 默认不是这样引用的·····springboot 多环境不需要这样配置····直接体现在yml配置文件中··
    
    2020-06-06 20:21:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
蚂蚁金服高级开发工程师萧恺:IDEA 插件开发入门教程 立即下载
使用Spring.Initializr定制工程脚手架 立即下载
陈曦:使用Spring.Initializr定制工程脚手架 立即下载

相关镜像