niaomingjian
niaomingjian

Reputation: 3742

spring boot failed to start after migrating from 1.5 to 2.0

After migrating from 1.5 to 2.0, I got the following error.

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

Description:

Binding to target [Bindable@7178d811 type = org.springframework.boot.autoconfigure.web.ServerProperties, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: server
    Value: 
    Origin: "server" from property source "class path resource [application.yml]"
    Reason: No converter found capable of converting from type [java.lang.String] to type [org.springframework.boot.autoconfigure.web.ServerProperties]

Action:

Update your application's configuration

After running an existing Junit Test, I got the error as follows:

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242)
    at com.nmj.cloud.api.RestfulCommandServiceTest.setUp(RestfulCommandServiceTest.java:917)
。。。。
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serverPropertiesWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'serverPropertiesWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties': prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
。。。。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serverPropertiesWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'serverPropertiesWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties': prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
。。。。
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serverPropertiesWebServerFactoryCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class]: Unsatisfied dependency expressed through method 'serverPropertiesWebServerFactoryCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties': prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
。。。。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties': prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
。。。。
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties
。。。。
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.boot.autoconfigure.web.ServerProperties]
。。。。

application.yml looks like the following: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

spring:
  resources:
    add-mappings: false
  mvc:
    throw-exception-if-no-handler-found: true
  autoconfigure.exclude:
    - org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration
    - org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration
    - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
    - org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
    - org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
    - org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
    - org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
    - org.springframework.boot.autoconfigure.data.RedisRepositoriesAutoConfiguration
    - org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration

mock:
  id: 1314

authentication:
  jwt:
    publickey: /pubkey.pem

analyze:
  url: http://localhost:8000/analyze

server:
  error:
    path: /error
  restTemplate:
    connectTimeout: 2000
    readTimeout: 2000

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have no idea how to update application's configuration. Could anyone give me some suggestions to fix this issue?

Upvotes: 1

Views: 4478

Answers (2)

Beat Jost
Beat Jost

Reputation: 350

Was there a solution to this problem? Have the same issuese after upgrading from SpringBoot 1.x to 2.5

implementation 'org.togglz:togglz-spring-boot-starter:2.9.7'
implementation 'org.togglz:togglz-console:2.9.7

Error when starting application...

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

Description:

Failed to bind properties under 'togglz.features.getnextovertime' to    org.togglz.spring.boot.actuate.autoconfigure.TogglzProperties$FeatureSpec:

Reason: No converter found capable of converting from type [java.lang.String] to type [org.togglz.spring.boot.actuate.autoconfigure.TogglzProperties$FeatureSpec]

Action:

Update your application's configuration

Upvotes: 0

Stephane Nicoll
Stephane Nicoll

Reputation: 33151

This is a bug in Spring Boot, please watch #10945 for updates.

Upvotes: 3

Related Questions