2017-07-19 58 views
0

我開始從Eclipse中我的春節,啓動應用程序與此VM參數ConverterNotFoundException:-Dserver.port = 80 noverify沒有找到兌換...字符串到整數

-Dserver.port=80 

enter image description here

應用.yml

server: 
    port: 8080 

,但我得到下面的異常「沒有找到轉換器能夠從[java.lang.String]類型轉換爲類型[java.lang.Integer]「

Running with Spring Boot v1.5.4.RELEASE, Spring v4.3.9.RELEASE 
... 

2017-07-19 11:26:55.299 ERROR 5968 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Properties configuration failed validation 
2017-07-19 11:26:55.299 ERROR 5968 --- [   main] o.s.b.b.PropertiesConfigurationFactory : Field error in object 'server' on field 'port': rejected value [80-noverify]; codes [typeMismatch.server.port,typeMismatch.port,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.port,port]; arguments []; default message [port]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]] 
Field error in object 'server' on field 'port': rejected value [80-noverify]; codes [typeMismatch.server.port,typeMismatch.port,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [server.port,port]; arguments []; default message [port]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer]] 

... 

*************************** 
APPLICATION FAILED TO START 
*************************** 

Description: 

Binding to target [email protected]daea failed: 

    Property: server.port 
    Value: 80-noverify 
    Reason: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'port'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.lang.Integer] 


Action: 

Update your application's configuration 

如果我使用屬性server.portapplication.yml它的作品,沒有任何問題。

我在做什麼錯?謝謝你的幫助。

+0

我們可以看看你的'application.yml'我懷疑你的端口字符串是這裏的問題 –

+0

你也可以顯示'pom.xml'嗎?看起來你只是缺少一個轉換器,你是否排除了Spring Boot帶來的任何依賴? – cahen

+0

http://stackoverflow.com/questions/37102273/environment-variables-and-value-cant-work-together-on-spring-boot –

回答

1

該問題是由彈簧引導運行配置引起的:在運行配置中,只需禁用「快速啓動」,問題就會消失。此選項會將-noverify添加爲VM參數,但不幸的是沒有空格。

+0

是的,這解決了問題,謝謝 – aliopi