Не может переопределить bootstrap.properties при запуске с другим профилем - PullRequest
0 голосов
/ 22 марта 2019

Я пытаюсь запустить Spring Boot в локальном профиле с помощью bootstrap-local.properties, но, похоже, он не работает.

В src / main / resourses у меня есть 2 файла: bootstrap.properties и bootstrap-local.properties.

bootstrap.properties

#Application Name
spring.application.name=configserver
#Server port
server.port=8888
# Github URL to connect remote Repository
spring.cloud.config.server.git.uri=https://github.com/TranNgocKhoa/config-respo
# Search path in the remote Repository
spring.cloud.config.server.git.search-paths=config-files*

bootstrap-local.properties

#Application Name
spring.application.name=configserver
#Server port
server.port=8888
# Github URL to connect remote Repository
spring.cloud.config.server.native.search-locations=classpath:/config-respo/config-files

Но когда я запускаю его с профилем local:

2019-03-22 11:20:14.398  INFO 11676 --- [           main] c.h.c.HellodoctorConfigserverApplication : The following profiles are active: local
2019-03-22 11:20:15.185  INFO 11676 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=ce04fc74-ea60-3e26-a1e0-957e7be20901
2019-03-22 11:20:15.210  INFO 11676 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$74797a93] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-22 11:20:15.489  INFO 11676 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8888 (http)
2019-03-22 11:20:15.514  INFO 11676 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-22 11:20:15.514  INFO 11676 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-03-22 11:20:15.523  INFO 11676 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_201\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_201\bin;C:\Program Files\PowerShell\6-preview\preview;C:\Program Files (x86)\VietPN;C:\Program Files\nodejs\;C:\Program Files\apache-maven-3.6.0\bin;C:\Program Files\Git\cmd;C:\Users\khoa1\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\khoa1\AppData\Local\Programs\Python\Python37\;C:\Users\khoa1\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\IntelliJ IDEA 2018.3.3\bin;;C:\Users\khoa1\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\khoa1\AppData\Roaming\npm;.]
2019-03-22 11:20:15.631  INFO 11676 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-22 11:20:15.631  INFO 11676 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1222 ms
2019-03-22 11:20:17.030  INFO 11676 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-22 11:20:18.049  INFO 11676 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-03-22 11:20:18.159  INFO 11676 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2019-03-22 11:20:18.162  INFO 11676 --- [           main] c.h.c.HellodoctorConfigserverApplication : Started HellodoctorConfigserverApplication in 7.492 seconds (JVM running for 9.255)
2019-03-22 11:20:19.073  INFO 11676 --- [on(1)-10.0.75.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-03-22 11:20:19.073  INFO 11676 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-03-22 11:20:19.082  INFO 11676 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms

Когда я запрашиваю конфигурацию, я получаю данные конфигурации, соответствующие при запуске в профиле default:

http://localhost:8888/hellodoctor-test-service/local


  "name": "hellodoctor-test-service",
  "profiles": [
    "local"
  ],
  "label": null,
  "version": "826b53db8aa62950cc42030ba19da8c1a39d3bc7",
  "state": null,
  "propertySources": [
    {
      "name": "https://github.com/TranNgocKhoa/config-respo/config-files/hellodoctor-test-service.yml",
      "source": {
        "spring.zipkin.baseUrl": "http://tracing-server:9411",
        "spring.application.name": "hellodoctor-test-service",
        "server.port": 8082,
        "eureka.client.serviceUrl.defaultZone": "http://${DNS_DISCOVERY_SERVER}:8761/eureka/"
      }
    }
  ]
}

Вы можете увидеть это в данных конфигурации: name": "https://github.com/TranNgocKhoa/config-respo/config-files/hellodoctor-test-service.yml

Я бы хотел получить из локального хранилища.

Как я могу это исправить? Спасибо.

...