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

After the spring cloud service project to enable the configuration, the configuration file can not be found 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 modify the configuration file yml

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

After submitting git, it restarts the current service program, error disappeared, normal start.

 

Note: Currently only write dead url address, spring cloud config discovery service did not work.

Published 161 original articles · won praise 39 · views 360 000 +

Guess you like

Origin blog.csdn.net/hknaruto/article/details/100013975