Spring Cloud (14) | 微服务不能从git/github/gitlab中获取数据库信息 can't load properties from git/github/gitlab

来源:互联网 发布:尼康失真控制数据 编辑:程序博客网 时间:2024/06/08 01:15

最近在spring cloud 部署的时候,发现之前可以从git/github/gitlab中获取数据库信息,但是现在不可以,可有的服务又可以,发现可以从git/github/gitlab中获取数据库信息的微服务,在启动的时候,打印Spring boot图标的下面,会打印出从git获取配置信息的如下:

2017-12-06 14:58:01.395  INFO 28442 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@44be0077: startup date [Wed Dec 06 14:58:01 CST 2017]; root of context hierarchy2017-12-06 14:58:02.659  INFO 28442 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring2017-12-06 14:58:02.904  INFO 28442 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$6f3a2897] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)  .   ____          _            __ _ _ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )  '  |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot ::        (v1.5.8.RELEASE)2017-12-06 14:58:04.196  INFO 28442 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:77772017-12-06 14:58:05.644  INFO 28442 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=spring-cloud--db, profiles=[test], label=master, version=11e3e075c6334e93a60daa1ecab4972aa0af62f2, state=null2017-12-06 14:58:05.645  INFO 28442 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='http://xxxx.xx:8080/spring/spring-cloud-config.git/spring-cloud--db-test.properties'}]]2017-12-06 14:58:05.655  INFO 28442 --- [           main] c.p.cloud.SpringApplication    : No active profile set, falling back to default profiles: default2017-12-06 14:58:05.693  INFO 28442 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4fa06f52: startup date [Wed Dec 06 14:58:05 CST 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@44be00772017-12-06 14:58:13.027  INFO 28442 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=9bb03dc1-29c6-3ed0-bd57-1f1685bc85eb2017-12-06 14:58:13.922  INFO 28442 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring2017-12-06 14:58:15.479  INFO 28442 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration' of type [org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration$$EnhancerBySpringCGLIB$$854ccbdb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2017-12-06 14:58:15.650  INFO 28442 --- [           main] trationDelegate$BeanPostProcessorChecker :

但是有的微服务就不能打印出上面的信息,寻找其中的区别,发现pom.xml文件中必须引入:spring-cloud-starter-config

    <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-config</artifactId>        </dependency>

这样就可以获取数据库配置信息了!

具体如何配置信息,请参考文章:

http://blog.csdn.net/superdangbo/article/details/78633439
http://blog.csdn.net/superdangbo/article/details/78633356

原创粉丝点击