解决spring cloud config导致class path resource [logback-spring.xml] cannot be resolved to URL

spring cloud 项目启用配置服务后,找不到logback-spring.xml配置文件

2019-08-22 13:54:58.056  INFO 28559 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2019-08-22 13:55:00.917  INFO 28559 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=service-provider, profiles=[dev], label=master, version=be51439ee38e31755a32f44651c6d716bc166d36, state=null
2019-08-22 13:55:00.918  INFO 28559 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='http://47.92.103.163/config_repo/springclouddemo-dev.git/service-provider-dev.yml'}]}
2019-08-22 13:55:00.924  WARN 28559 --- [           main] b.c.PropertySourceBootstrapConfiguration : Error opening logging config file classpath:logback-spring.xml

java.io.FileNotFoundException: class path resource [logback-spring.xml] cannot be resolved to URL because it does not exist
	at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:137) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.reinitializeLoggingSystem(PropertySourceBootstrapConfiguration.java:130) [spring-cloud-context-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:113) [spring-cloud-context-2.1.2.RELEASE.jar:2.1.2.RELEASE]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:621) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:365) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at com.hknaruto.ServiceProviderApp.main(ServiceProviderApp.java:12) [classes/:na]

修改git中的配置文件yml

logging:
        config: http://127.0.0.1:8888/*/default/master/logback-spring.xml

提交git后,重启当前服务程序,报错消失,正常启动。

说明: 目前只能写死url地址, spring cloud config 发现服务没有起作用。

发布了161 篇原创文章 · 获赞 39 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/hknaruto/article/details/100013975