如果沒有出現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@'