ConverterNotFoundException:-Dserver.port = 80-noverify未找到转换器... String to Integer

时间:2017-07-19 09:37:27

标签: spring-boot

我正在使用此VM参数

从Eclipse启动Spring Boot应用程序
-Dserver.port=80

enter image description here

application.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 org.springframework.boot.autoconfigure.web.ServerProperties@caaddaea 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.port中使用了application.yml这个属性,那就没问题。

我做错了什么?谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

问题是由弹簧启动运行配置引起的:在运行配置中,只需禁用“快速启动”,问题就会消失。此选项导致-noverify被添加为VM参数,但遗憾的是,没有空格。