如果没有出现profiles,那么是在pom中缺少以下配置
<profiles>
<profile>
<id>local</id>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>local</profiles.active>
<logging.level>debug</logging.level>
<logging.org.springframework>warn</logging.org.springframework>
</properties>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>dev</id>
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
<logging.level>debug</logging.level>
<logging.org.springframework>warn</logging.org.springframework>
</properties>
</profile>
</profiles>
出现效果如下:
- 如果加了之后出现以下异常,那么可以直接
found character '@' that cannot start any token. (Do not use @ for indentation) in 'reader', line 3, column 13: active: @profiles.active@
直接maven来更新update一边基本可以搞定,实在不行就修改为如下,加上单引号或者双引号
spring:
profiles:
active: '@profiles.active@'