springboot application.yml使用@@pom文件配置問題
springboot application.yml使用@@pom文件配置
這幾天搞了一下mongodb到springboot 在配置我使用了yml的配置文件 在引用pom文件配置時需要進行配置才可以使用@@
<build> ? ? ? ? <!-- 使用 @@ application.yml 獲取pom文件中的配置 ?--> ? ? ? ? <resources> ? ? ? ? ? ? <resource> ? ? ? ? ? ? ? ? <directory>src/main/resources</directory> ? ? ? ? ? ? ? ? <filtering>true</filtering> ? ? ? ? ? ? </resource> ? ? ? ? </resources> </build>
如果沒有配置指定resources的話 在使用@@獲取pom文件配置的時候就會爆出:
'@' that cannot start any token. (Do not use @ for indentation)
springboot中application.yaml無法使用@@讀取pom.xml中標(biāo)簽值的問題
application.yaml文件讀取不到pom.xml下的標(biāo)簽值,報
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 7, column 13:
active: @spring.profiles.active@
解決方法
在模塊的pom.xml文件下寫入
<build> ? ? <!--重要 如果不設(shè)置resource 會導(dǎo)致application.yaml中的@@找不到pom文件中的配置--> ? ? <resources> ? ? ? ? <resource> ? ? ? ? ? ? <directory>src/main/resources</directory> ? ? ? ? ? ? <filtering>true</filtering> ? ? ? ? </resource> ? ? </resources> ? ? <!--重要 如果不設(shè)置resource 會導(dǎo)致application.yaml中的@@找不到pom文件中的配置--> ? ? <plugins> ? ? ? ? <plugin> ? ? ? ? ? ? <groupId>org.springframework.boot</groupId> ? ? ? ? ? ? <artifactId>spring-boot-maven-plugin</artifactId> ? ? ? ? </plugin> ? ? </plugins> </build>
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
應(yīng)用啟動數(shù)據(jù)初始化接口CommandLineRunner和Application詳解
這篇文章主要介紹了應(yīng)用啟動數(shù)據(jù)初始化接口CommandLineRunner和Application詳解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-12-12Java中s.charAt(index)用于提取字符串s中的特定字符操作
這篇文章主要介紹了Java中s.charAt(index)用于提取字符串s中的特定字符操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10intellij idea修改maven配置時總是恢復(fù)默認(rèn)配置的解決方法idea版本(2020.2.x)
這篇文章主要介紹了intellij idea修改maven配置時總是恢復(fù)默認(rèn)配置的解決方法idea版本(2020.2.x),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-08-08IDEA 集成log4j將SQL語句打印在控制臺上的實現(xiàn)操作
這篇文章主要介紹了IDEA 集成log4j將SQL語句打印在控制臺上的實現(xiàn)操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02