在yml配置文件使用maven的配置引用报错:ERROR org.springframework.boot.SpringApplication - Application run failed
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: @activeProfile@
spring:
profiles:
active: @activeProfile@
解决办法:
在maven加上如下配置(修改配置后记住mvn clean install一下)
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
完整配置:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
使用不用加单引号或双引号,就@activeProfile@即可。