使用config-server和config-client,配置后已经调通,新建的client服务可以从git上拉取配置文件。但是当在另外一个client服务上使用后,运行时报错:org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.String]。具体信息如下:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.String]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.convertValueIfNecessary(AbstractPropertyResolver.java:263) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:91) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:62) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:535) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.logging.LogFile.get(LogFile.java:116) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.reinitializeLoggingSystem(PropertySourceBootstrapConfiguration.java:122) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:110) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:636) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:376) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at com.ujs.recore.RecoreApplication.main(RecoreApplication.java:31) [classes/:na]
于是尝试将Git上配置文件的其余配置信息全部去掉,只留下server.port的配置。结果报错:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-12-23 17:07:09.379 ERROR 28640 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: {value=80, origin=2:11}
Origin: "server.port" from property source "bootstrapProperties"
Reason: No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.Integer]
Action:
Update your application's configuration
Process finished with exit code 1
目前问题待解决,解决完来更新。
附调试过程中发现的注意点:
1.例如Spring.application和spring.cloud,这两个要写在同一个spring下,不要分成两部分,比如上面写一个spring.application,中间写server.port,后面又写spring.cloud,就会报以下错误:java.lang.IllegalStateException: Failed to load property source from location ‘classpath:/bootstrap.yml’。具体报错信息如下:
10:07:42.877 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/bootstrap.yml'
*(省略......)*
Caused by: org.yaml.snakeyaml.constructor.DuplicateKeyException: while constructing a mapping
in 'reader', line 1, column 1:
spring:
^
found duplicate key spring
in 'reader', line 46, column 1:
spring:
^
*(省略......)*