即使在bootstrap.properties中提供了应用程序名称和URI之后,配置服务器(JDBC后端)也无法找到属性源

时间:2019-04-03 19:54:49

标签: java spring-boot spring-cloud spring-boot-actuator spring-cloud-config

我正在使用Spring cloud config设置配置管理器,但遇到一个问题,当我将应用程序部署到Azure上的Docker容器时,客户端无法获取属性源(托管HTTPS服务器URI)当在使用相同URI的Localhost上运行相同的代码时,对如何继续进行思考?

我在bootstrap.properties中提供了所有必需的参数,包括应用程序名称和SERVER URI以及活动配置文件(dev)和标签(1.0),我还尝试通过将management.security.enabled设置为禁用安全性错误地认为这是一个安全问题,但似乎找不到资源的来源。 (最坏的情况是,当客户端在本地运行时,HTTPS服务器URI似乎已定位),仅当使用Docker容器化代码并将其部署到Azure时,才显示此行为。任何帮助,不胜感激!

P.S-处理SpringBoot 2.1.3的最新快照和Spring Cloud starter 2.1.1的最新快照,我添加的任何依赖项都没有问题。

   <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <org.apache.commons.version>3.5</org.apache.commons.version>
        <java.version>1.8</java.version>
        <lombok.version>1.16.12</lombok.version>
        <apt.version>1.1.3</apt.version>
        <querydsl.version>4.1.4</querydsl.version>
        <log4j-api.version>2.6</log4j-api.version>
    </properties>


      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
            <version>2.1.1.RELEASE</version>
        </dependency>



bootstrap.properties

spring.cloud.config.uri=example.org
spring.application.name=MyApp
spring.profiles.active=dev
spring.cloud.config.profile=dev
spring.cloud.config.label=1.0

application.properties

management.endpoints.web.exposure.include=*

Expected when running on Localhost

2019-04-03 14:48:42.499  INFO 50217 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : example.org
2019-04-03 14:48:43.961  INFO 50217 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=MyApp, profiles=[dev], label=1.0, version=null, state=null
2019-04-03 14:48:43.961  INFO 50217 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='MyApp-dev'}]}
2019-04-03 14:48:43.965  INFO 50217 --- [           main] c.s.c.backroom.claims.ClaimsApplication  : The following profiles are active: dev
2019-04-03 14:48:44.985  INFO 50217 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-03 14:48:45.135  INFO 50217 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 138ms. Found 17 repository interfaces.
2019-04-03 14:48:45.929  INFO 50217 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=1f523ae6-9bf7-3733-ae13-ea87a67e1564
201

Actual Result when running on Docker container on Azure

2019-04-03T17:35:03.470926214Z 2019-04-03 17:35:03.470  INFO 8 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : example.org

2019-04-03T17:35:09.723760869Z 2019-04-03 17:35:09.723  WARN 8 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: Could not extract response: no suitable HttpMessageConverter found for response type [class org.springframework.cloud.config.environment.Environment] and content type [text/html;charset=ISO-8859-1]
2019-04-03T17:35:09.752928427Z 2019-04-03 17:35:09.752  INFO 8 --- [           main] c.s.c.backroom.claims.ClaimsApplication  : The following profiles are active: dev

2019-04-03T17:35:19.974721803Z 2019-04-03 17:35:19.971  INFO 8 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.

0 个答案:

没有答案