spring boot从git上拉取配置文件,报错:org.springframework.core.convert.ConverterNotFoundException

使用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:
    ^
*(省略......)*
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值