2016-04-25 38 views
2

我們的應用程序針對我們從Maven項目文件動態獲取的屬性。從Eclipse切換到IntelliJ後,彈簧引導屬性擴展不起作用

info: 
    build: 
    artifact: @[email protected] 
    name: @[email protected] 
    description: @[email protected] 
    version: @[email protected] 

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-application-info-automatic-expansion-maven

當我們使用Eclipse這些都不是問題,但現在移動到InelliJ應用程序將不會啓動,除非我對那些動態特性提供一些硬編碼值。

我得到這個錯誤:

19:47:20.962 [main] INFO com.edlogics.ElrcApplication - Spring Boot configuration: profiles = [local, chris] 
19:47:20.968 [main] INFO com.edlogics.ElrcApplication - Spring Boot configuration: properties = {} 
Exception in thread "main" while scanning for the next token 
found character '@' that cannot start any token. (Do not use @ for indentation) 
in 'reader', line 74, column 11: 
     name: @[email protected] 
      ^

org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420) 
org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) 
org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586) 
org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) 
org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) 
org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) 
org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) 
org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) 
org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) 
org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) 
org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:229) 
org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) 
org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) 
... 

Process finished with exit code 1 

我意識到@不是有效YAML的性格,只是不知道如何在Eclipse中工作,而不是在的IntelliJ

編輯:

我從原始問題中排除的一件事是我們有一個多模塊項目。這是項目的根POM,從彈簧引導起動家長有這個繼承:

 <resources> 
     <resource> 
      <directory>${basedir}/src/main/resources</directory> 
      <filtering>true</filtering> 
      <includes> 
       <include>**/application.yml</include> 
       <include>**/application.properties</include> 
      </includes> 
     </resource> 
     <resource> 
      <directory>${basedir}/src/main/resources</directory> 
      <excludes> 
       <exclude>**/application.yml</exclude> 
       <exclude>**/application.properties</exclude> 
      </excludes> 
     </resource> 
    </resources> 

而且在我們的項目是一個子模塊是需要過濾的。 application.yml文件位於子模塊的正確位置,Eclipse似乎並不介意它是子模塊。我知道Eclipse和IntelliJ對待多模塊項目有點不同(Eclipse具有扁平結構,而IntelliJ是分層結構)。

+0

似乎您使用Maven機制來過濾資源,並且Eclipse在構建期間使用配置執行了maven插件,而IntelliJ則沒有。我不知道你如何告訴IntelliJ這樣做,但至少你有更多的關鍵字需要尋找。 – dunni

+0

根據https://www.jetbrains.com/help/idea/2016.1/maven.html?origin=old_help#compile它應該開箱即用。你可能有一個自定義文件夾佈局?你能顯示你的pom.xml和文件夾結構嗎? – dunni

+0

完全不相關,但好消息是[你不必用1.4來做到這一點](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-現成的應用程序信息,版本)。說了它對我有用,所以可能會有一些與您的項目設置有關的特定內容。 –

回答

2

原來,資源過濾在IntelliJ中工作。在未被正確過濾的四個中有一個屬性@[email protected]。不知何故,這在Eclipse中不是問題。所以我們只是從application.yml中刪除了這個屬性,因爲我們沒有使用它。

相關問題