Spring Cloud SpringCloud 自学课程2 SpringCloud Configuration Server -- 访问Git上的配置文件

实例代码:https://github.com/michaelzhanghe/springcloud-02-confsrv.git

在Git上的配置文件: https://github.com/michaelzhanghe/springcloud-config-repo.git


-----------------------Windows10-----------------------




pom.xml加入Json依赖

		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.9.5</version>
		</dependency>

加入注解@EnableConfigServer已开启configuration server功能





创建保存configuration的文件,提供给其他服务进行rest远程调用configuration properties, 命名规则是应用名字加上“-”加上环境名字的YAML配置文件。


暴露8888访问端口,配置文件存储在git上, searchPaths配置查找的路径。

server:
  port: 8888
spring:
  cloud:
    config:
      server:
        encrypt.enabled: false
        git:
          uri: https://github.com/michaelzhanghe/springcloud-config-repo
          searchPaths: licensingservice,organizationservice
          username: 改为自己的github的登录名
          password: 改为自己的github的登录密码
2018-04-17 18:37:05.407  INFO 236 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@411f53a0: startup date [Tue Apr 17 18:37:05 CST 2018]; root of context hierarchy
2018-04-17 18:37:05.630  INFO 236 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$859e9b21] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.1.RELEASE)

2018-04-17 18:37:07.119  INFO 236 --- [           main] c.c.Springcloud02ConfsrvApplication      : No active profile set, falling back to default profiles: default
2018-04-17 18:37:07.131  INFO 236 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6986bbaf: startup date [Tue Apr 17 18:37:07 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@411f53a0
2018-04-17 18:37:07.636  INFO 236 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'environmentWebEndpointExtension' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration$EndpointConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/LifecycleMvcEndpointAutoConfiguration$EndpointConfiguration.class]]
2018-04-17 18:37:07.892  INFO 236 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=06a920f8-4e72-3672-9ad1-5bc768bf7934
2018-04-17 18:37:07.959  INFO 236 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$859e9b21] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-17 18:37:08.267  INFO 236 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8888 (http)
2018-04-17 18:37:08.344  INFO 236 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-04-17 18:37:08.344  INFO 236 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-17 18:37:08.352  INFO 236 --- [ost-startStop-1] 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_151\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_151/bin/server;C:/Program Files/Java/jre1.8.0_151/bin;C:/Program Files/Java/jre1.8.0_151/lib/amd64;C:\Program Files\IBM\WebSphere MQ\java\lib;C:\Program Files\IBM\WebSphere MQ\java\lib64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\work\dev tools doc\apache-maven-3.5.2\bin;C:\work\dev tools doc\sqlplus_client_12_2;C:\work\dev tools doc\sqlplus_client_12_2\instantclient_12_2_sdk;C:\Windows\system32\wbem;C:\Program Files (x86)\IVT Corporation\BlueSoleil\Mobile;C:\Program Files\IBM\WebSphere MQ\bin64;C:\Program Files\IBM\WebSphere MQ\bin;C:\Program Files\IBM\WebSphere MQ\tools\c\samples\bin;C:\Program Files\IBM\Bluemix\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\work\dev tools doc\spring-tool-suite-3.9.1.RELEASE-e4.7.1a-win32-x86_64\sts-bundle\sts-3.9.1.RELEASE;;.]
2018-04-17 18:37:08.454  INFO 236 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-04-17 18:37:08.454  INFO 236 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1323 ms
2018-04-17 18:37:09.411  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-04-17 18:37:09.415  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-17 18:37:09.416  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-17 18:37:09.416  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-17 18:37:09.416  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-17 18:37:09.416  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
2018-04-17 18:37:09.416  INFO 236 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-04-17 18:37:09.531  INFO 236 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 18:37:09.717  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6986bbaf: startup date [Tue Apr 17 18:37:07 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@411f53a0
2018-04-17 18:37:09.787  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-04-17 18:37:09.788  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-17 18:37:09.794  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,org.springframework.http.MediaType)
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/decrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/decrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,org.springframework.http.MediaType)
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt/status],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.config.server.encryption.EncryptionController.status()
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/key],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.getPublicKey()
2018-04-17 18:37:09.795  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/key/{name}/{profiles}],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.getPublicKey(java.lang.String,java.lang.String)
2018-04-17 18:37:09.801  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.properties(java.lang.String,java.lang.String,boolean) throws java.io.IOException
2018-04-17 18:37:09.801  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.yml || /{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.yaml(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 18:37:09.801  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledJsonProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 18:37:09.801  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.io.IOException
2018-04-17 18:37:09.801  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profiles:.*[^-].*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(java.lang.String,java.lang.String)
2018-04-17 18:37:09.802  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profiles}/{label:.*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController.labelled(java.lang.String,java.lang.String,java.lang.String)
2018-04-17 18:37:09.802  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.jsonProperties(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 18:37:09.802  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.yml || /{label}/{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 18:37:09.806  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/**],methods=[GET],params=[useDefaultLabel]}" onto public java.lang.String org.springframework.cloud.config.server.resource.ResourceController.retrieve(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,boolean) throws java.io.IOException
2018-04-17 18:37:09.807  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/{label}/**],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.resource.ResourceController.retrieve(java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,boolean) throws java.io.IOException
2018-04-17 18:37:09.807  INFO 236 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/{label}/**],methods=[GET],produces=[application/octet-stream]}" onto public synchronized byte[] org.springframework.cloud.config.server.resource.ResourceController.binary(java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest) throws java.io.IOException
2018-04-17 18:37:09.833  INFO 236 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 18:37:09.834  INFO 236 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 18:37:11.187  INFO 236 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2018-04-17 18:37:11.289  INFO 236 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2018-04-17 18:37:11.297  INFO 236 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-04-17 18:37:11.297  INFO 236 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-04-17 18:37:11.298  INFO 236 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-17 18:37:11.346  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-04-17 18:37:11.355  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-04-17 18:37:11.356  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-04-17 18:37:11.357  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-04-17 18:37:11.359  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-04-17 18:37:11.369  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-04-17 18:37:11.379  INFO 236 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=6986bbaf,type=ConfigurationPropertiesRebinder]
2018-04-17 18:37:11.436  INFO 236 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2018-04-17 18:37:11.440  INFO 236 --- [           main] c.c.Springcloud02ConfsrvApplication      : Started Springcloud02ConfsrvApplication in 7.524 seconds (JVM running for 7.922)
2018-04-17 18:37:16.943  INFO 236 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-04-17 18:37:16.943  INFO 236 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-04-17 18:37:16.957  INFO 236 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 14 ms
2018-04-17 18:37:23.526  INFO 236 --- [nio-8888-exec-1] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2018-04-17 18:37:23.587  INFO 236 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3322fe46: startup date [Tue Apr 17 18:37:23 CST 2018]; root of context hierarchy
2018-04-17 18:37:23.635  INFO 236 --- [nio-8888-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/C:/Users/Administrator/AppData/Local/Temp/config-repo-8017782463306449746/licensingservice/licensingservice.yml
2018-04-17 18:37:23.635  INFO 236 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3322fe46: startup date [Tue Apr 17 18:37:23 CST 2018]; root of context hierarchy
2018-04-17 18:37:30.805  INFO 236 --- [nio-8888-exec-3] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2018-04-17 18:37:30.832  INFO 236 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1c019cda: startup date [Tue Apr 17 18:37:30 CST 2018]; root of context hierarchy
2018-04-17 18:37:30.841  INFO 236 --- [nio-8888-exec-3] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/C:/Users/Administrator/AppData/Local/Temp/config-repo-8017782463306449746/licensingservice/licensingservice-dev.yml
2018-04-17 18:37:30.841  INFO 236 --- [nio-8888-exec-3] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/C:/Users/Administrator/AppData/Local/Temp/config-repo-8017782463306449746/licensingservice/licensingservice.yml
2018-04-17 18:37:30.841  INFO 236 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1c019cda: startup date [Tue Apr 17 18:37:30 CST 2018]; root of context hierarchy

加入/springcloud-02-confsrv/src/main/docker/Dockerfile,JCE是加密工具

FROM openjdk:8-jdk-alpine
RUN  apk update && apk upgrade && apk add netcat-openbsd && apk add curl
RUN mkdir -p /usr/local/configserver
RUN echo $JAVA_HOME
RUN cd /tmp/ && \
    curl -k -LO "http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip" -H 'Cookie: oraclelicense=accept-securebackup-cookie' && \
    unzip jce_policy-8.zip && \
    rm jce_policy-8.zip && \
    yes |cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
RUN mkdir -p /home/michael01/springcloudroot/
ADD @project.build.finalName@.jar /home/michael01/springcloudroot/
ENTRYPOINT ["/usr/bin/java", "-jar", "/home/michael01/springcloudroot/@project.build.finalName@.jar"]

加入创建docker镜像的插件

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-resources</id>
						<!-- here the phase you need -->
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}/target/dockerfile</outputDirectory>
							<resources>
								<resource>
									<directory>src/main/docker</directory>
									<filtering>true</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.4.10</version>
				<configuration>
					<imageName>${docker.image.name}:${docker.image.tag}</imageName>
					<dockerDirectory>${basedir}/target/dockerfile</dockerDirectory>
					<resources>
						<resource>
							<targetPath>/</targetPath>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
					</resources>
				</configuration>
			</plugin>
		</plugins>
	</build>


-----------------------linux-----------------------


michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ mvn clean package docker:build
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------< com.cloudlearning:springcloud-02-confsrv >--------------
[INFO] Building springcloud-02-confsrv 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ springcloud-02-confsrv ---
[INFO] Deleting /home/michael01/springcloudroot/springcloud-02-confsrv/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:copy-resources (copy-resources) @ springcloud-02-confsrv ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ springcloud-02-confsrv ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ springcloud-02-confsrv ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/michael01/springcloudroot/springcloud-02-confsrv/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ springcloud-02-confsrv ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/michael01/springcloudroot/springcloud-02-confsrv/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ springcloud-02-confsrv ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/michael01/springcloudroot/springcloud-02-confsrv/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ springcloud-02-confsrv ---
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ springcloud-02-confsrv ---
[INFO] Building jar: /home/michael01/springcloudroot/springcloud-02-confsrv/target/springcloud-02-confsrv-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ springcloud-02-confsrv ---
[INFO] 
[INFO] --- docker-maven-plugin:0.4.10:build (default-cli) @ springcloud-02-confsrv ---
[INFO] Copying /home/michael01/springcloudroot/springcloud-02-confsrv/target/springcloud-02-confsrv-0.0.1-SNAPSHOT.jar -> /home/michael01/springcloudroot/springcloud-02-confsrv/target/docker/springcloud-02-confsrv-0.0.1-SNAPSHOT.jar
[INFO] Copying /home/michael01/springcloudroot/springcloud-02-confsrv/target/dockerfile/Dockerfile -> /home/michael01/springcloudroot/springcloud-02-confsrv/target/docker/Dockerfile
[INFO] Building image springcloud-02/confsrv:0.0.1-SNAPSHOT
Step 1/8 : FROM openjdk:8-jdk-alpine

Pulling from library/openjdk
ff3a5c916c92: Already exists 
5de5f69f42d7: Already exists 
fd869c8b9b59: Already exists 
Digest: sha256:e82316151c501a2a0f73b3089da8dc867816470a464fcb191db9f88c2343ad53
Status: Downloaded newer image for openjdk:8-jdk-alpine
 ---> 224765a6bdbe
Step 2/8 : RUN  apk update && apk upgrade && apk add netcat-openbsd && apk add curl

 ---> Running in c7bc9ac7a0ab
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-149-g46ab307937 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-150-g3ea1ba4100 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 9051 distinct packages available
Upgrading critical system libraries and apk-tools:
(1/1) Upgrading apk-tools (2.8.2-r0 -> 2.9.1-r2)
Executing busybox-1.27.2-r7.trigger
Continuing the upgrade transaction with new apk-tools:
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/4) Upgrading musl (1.1.18-r2 -> 1.1.18-r3)
(2/4) Upgrading busybox (1.27.2-r7 -> 1.27.2-r8)
Executing busybox-1.27.2-r8.post-upgrade
(3/4) Upgrading musl-utils (1.1.18-r2 -> 1.1.18-r3)
(4/4) Upgrading libtasn1 (4.12-r2 -> 4.12-r3)
Executing busybox-1.27.2-r8.trigger
OK: 100 MiB in 51 packages
(1/1) Installing netcat-openbsd (1.130-r1)
Executing busybox-1.27.2-r8.trigger
OK: 100 MiB in 52 packages
(1/3) Installing libssh2 (1.8.0-r2)
(2/3) Installing libcurl (7.59.0-r0)
(3/3) Installing curl (7.59.0-r0)
Executing busybox-1.27.2-r8.trigger
OK: 100 MiB in 55 packages
Removing intermediate container c7bc9ac7a0ab
 ---> 1a9ae051d615
Step 3/8 : RUN mkdir -p /usr/local/configserver

 ---> Running in 722d924c0586
Removing intermediate container 722d924c0586
 ---> da15bd8edf4c
Step 4/8 : RUN echo $JAVA_HOME

 ---> Running in 27c82182949a
/usr/lib/jvm/java-1.8-openjdk
Removing intermediate container 27c82182949a
 ---> 5037f86d7153
Step 5/8 : RUN cd /tmp/ &&     curl -k -LO "http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip" -H 'Cookie: oraclelicense=accept-securebackup-cookie' &&     unzip jce_policy-8.zip &&     rm jce_policy-8.zip &&     yes |cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/

 ---> Running in 1f895f593b7d
 
 
%
 
T
o
t
a
l
 
 
 
 
%
 
R
e
c
e
ived % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100   429  100   429    0     0    375      0  0:00:01  0:00:01 --:--:--     0

100  8409  100  8409    0     0   6523      0  0:00:01  0:00:01 --:--:--  6523

Archive:  jce_policy-8.zip
   creating: UnlimitedJCEPolicyJDK8/
  inflating: UnlimitedJCEPolicyJDK8/local_policy.jar
  inflating: UnlimitedJCEPolicyJDK8/README.txt
  inflating: UnlimitedJCEPolicyJDK8/US_export_policy.jar
'/tmp/UnlimitedJCEPolicyJDK8/US_export_policy.jar' -> '/usr/lib/jvm/java-1.8-openjdk/jre/lib/security/US_export_policy.jar'
'/tmp/UnlimitedJCEPolicyJDK8/local_policy.jar' -> '/usr/lib/jvm/java-1.8-openjdk/jre/lib/security/local_policy.jar'
Removing intermediate container 1f895f593b7d
 ---> 6abdfac52d09
Step 6/8 : RUN mkdir -p /home/michael01/springcloudroot/

 ---> Running in e99b91cc46a0
Removing intermediate container e99b91cc46a0
 ---> a51a0948c727
Step 7/8 : ADD springcloud-02-confsrv-0.0.1-SNAPSHOT.jar /home/michael01/springcloudroot/

 ---> 3cc0878ece03
Step 8/8 : ENTRYPOINT ["/usr/bin/java", "-jar", "/home/michael01/springcloudroot/springcloud-02-confsrv-0.0.1-SNAPSHOT.jar"]

 ---> Running in be29670812ed
Removing intermediate container be29670812ed
 ---> 233b4584ad84
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built 233b4584ad84
Successfully tagged springcloud-02/confsrv:0.0.1-SNAPSHOT
[INFO] Built springcloud-02/confsrv:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:18 min
[INFO] Finished at: 2018-04-17T22:02:41+08:00
[INFO] ------------------------------------------------------------------------
michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ 

michael01@michael01-ubuntu01:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

michael01@michael01-ubuntu01:~$ docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
springcloud-02/confsrv              0.0.1-SNAPSHOT      233b4584ad84        15 seconds ago      132MB
springcloud-01/hello                0.0.1-SNAPSHOT      a524d56e3fd4        24 hours ago        101MB
<none>                              <none>              722c72220227        24 hours ago        101MB
192.168.231.133:5000/busybox        latest              8ac48589692a        12 days ago         1.15MB
postgres                            9.5                 5c5aa9a16b8b        4 weeks ago         264MB
johncarnell/tmx-licensing-service   chapter3            932c2ebbf884        2 months ago        138MB
johncarnell/tmx-confsvr             chapter3            ee14e08f813b        2 months ago        128MB
openjdk                             8-jre-alpine        b1bd879ca9b3        3 months ago        82MB
openjdk                             8-jdk-alpine        224765a6bdbe        3 months ago        102MB
michael01@michael01-ubuntu01:~$ 

michael01@michael01-ubuntu01:~$ docker run -p 8888:8888 233b4584ad84
2018-04-17 14:06:24.448  INFO 1 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2aaf7cc2: startup date [Tue Apr 17 14:06:24 GMT 2018]; root of context hierarchy
2018-04-17 14:06:26.921  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$469fcdad] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.1.RELEASE)

2018-04-17 14:06:28.222  INFO 1 --- [           main] c.c.Springcloud02ConfsrvApplication      : No active profile set, falling back to default profiles: default
2018-04-17 14:06:28.325  INFO 1 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@148080bb: startup date [Tue Apr 17 14:06:28 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2aaf7cc2
2018-04-17 14:06:31.348  INFO 1 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'environmentWebEndpointExtension' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration$EndpointConfiguration; factoryMethodName=environmentWebEndpointExtension; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/autoconfigure/LifecycleMvcEndpointAutoConfiguration$EndpointConfiguration.class]]
2018-04-17 14:06:32.783  INFO 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=06a920f8-4e72-3672-9ad1-5bc768bf7934
2018-04-17 14:06:33.100  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$469fcdad] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-17 14:06:34.322  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8888 (http)
2018-04-17 14:06:34.479  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-04-17 14:06:34.480  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-17 14:06:34.549  INFO 1 --- [ost-startStop-1] 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: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-04-17 14:06:34.914  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-04-17 14:06:34.920  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 6595 ms
2018-04-17 14:06:38.560  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-04-17 14:06:38.584  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-17 14:06:38.586  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-17 14:06:38.587  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-17 14:06:38.591  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-17 14:06:38.593  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
2018-04-17 14:06:38.596  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-04-17 14:06:38.951  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 14:06:39.648  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@148080bb: startup date [Tue Apr 17 14:06:28 GMT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2aaf7cc2
2018-04-17 14:06:39.911  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-17 14:06:39.922  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-04-17 14:06:39.954  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,org.springframework.http.MediaType)
2018-04-17 14:06:39.962  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.encrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-04-17 14:06:39.968  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/decrypt/{name}/{profiles}],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,java.lang.String,java.lang.String,org.springframework.http.MediaType)
2018-04-17 14:06:39.976  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/decrypt],methods=[POST]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.decrypt(java.lang.String,org.springframework.http.MediaType)
2018-04-17 14:06:39.977  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt/status],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.cloud.config.server.encryption.EncryptionController.status()
2018-04-17 14:06:39.978  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/key],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.getPublicKey()
2018-04-17 14:06:39.979  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/key/{name}/{profiles}],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.encryption.EncryptionController.getPublicKey(java.lang.String,java.lang.String)
2018-04-17 14:06:40.007  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.properties(java.lang.String,java.lang.String,boolean) throws java.io.IOException
2018-04-17 14:06:40.013  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.yml || /{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.yaml(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 14:06:40.015  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profiles}/{label:.*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController.labelled(java.lang.String,java.lang.String,java.lang.String)
2018-04-17 14:06:40.024  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profiles:.*[^-].*}],methods=[GET]}" onto public org.springframework.cloud.config.environment.Environment org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(java.lang.String,java.lang.String)
2018-04-17 14:06:40.037  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.yml || /{label}/{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 14:06:40.039  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.io.IOException
2018-04-17 14:06:40.040  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.jsonProperties(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 14:06:40.040  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.lang.String> org.springframework.cloud.config.server.environment.EnvironmentController.labelledJsonProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2018-04-17 14:06:40.069  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/{label}/**],methods=[GET],produces=[application/octet-stream]}" onto public synchronized byte[] org.springframework.cloud.config.server.resource.ResourceController.binary(java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest) throws java.io.IOException
2018-04-17 14:06:40.072  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/**],methods=[GET],params=[useDefaultLabel]}" onto public java.lang.String org.springframework.cloud.config.server.resource.ResourceController.retrieve(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,boolean) throws java.io.IOException
2018-04-17 14:06:40.073  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}/{profile}/{label}/**],methods=[GET]}" onto public java.lang.String org.springframework.cloud.config.server.resource.ResourceController.retrieve(java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,boolean) throws java.io.IOException
2018-04-17 14:06:40.172  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 14:06:40.179  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-17 14:06:41.852  INFO 1 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2018-04-17 14:06:41.887  INFO 1 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-04-17 14:06:41.902  INFO 1 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-04-17 14:06:41.905  INFO 1 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-17 14:06:42.145  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-04-17 14:06:42.180  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2018-04-17 14:06:42.191  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure
2018-04-17 14:06:42.195  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure
2018-04-17 14:06:42.207  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2018-04-17 14:06:42.252  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2018-04-17 14:06:42.301  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=148080bb,type=ConfigurationPropertiesRebinder]
2018-04-17 14:06:42.472  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2018-04-17 14:06:42.497  INFO 1 --- [           main] c.c.Springcloud02ConfsrvApplication      : Started Springcloud02ConfsrvApplication in 21.715 seconds (JVM running for 23.712)
2018-04-17 14:07:06.701  INFO 1 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-04-17 14:07:06.710  INFO 1 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-04-17 14:07:06.868  INFO 1 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 158 ms
2018-04-17 14:07:17.201  INFO 1 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@548e7252: startup date [Tue Apr 17 14:07:17 GMT 2018]; root of context hierarchy
2018-04-17 14:07:17.385  INFO 1 --- [nio-8888-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/tmp/config-repo-2693107344800461181/licensingservice/licensingservice-dev.yml
2018-04-17 14:07:17.386  INFO 1 --- [nio-8888-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/tmp/config-repo-2693107344800461181/licensingservice/licensingservice.yml
2018-04-17 14:07:17.387  INFO 1 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@548e7252: startup date [Tue Apr 17 14:07:17 GMT 2018]; root of context hierarchy
2018-04-17 14:07:27.277  INFO 1 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5c041c4a: startup date [Tue Apr 17 14:07:27 GMT 2018]; root of context hierarchy
2018-04-17 14:07:27.307  INFO 1 --- [nio-8888-exec-3] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/tmp/config-repo-2693107344800461181/licensingservice/licensingservice.yml
2018-04-17 14:07:27.308  INFO 1 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5c041c4a: startup date [Tue Apr 17 14:07:27 GMT 2018]; root of context hierarchy
2018-04-17 14:07:45.902  INFO 1 --- [nio-8888-exec-4] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7da24d48: startup date [Tue Apr 17 14:07:45 GMT 2018]; root of context hierarchy
2018-04-17 14:07:46.039  INFO 1 --- [nio-8888-exec-4] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/tmp/config-repo-2693107344800461181/licensingservice/licensingservice-prod.yml
2018-04-17 14:07:46.041  INFO 1 --- [nio-8888-exec-4] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/tmp/config-repo-2693107344800461181/licensingservice/licensingservice.yml
2018-04-17 14:07:46.041  INFO 1 --- [nio-8888-exec-4] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7da24d48: startup date [Tue Apr 17 14:07:45 GMT 2018]; root of context hierarchy


分别测试调用dev,default,prod3个环境的配置文件内容

michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ curl http://localhost:8888/licensingservice/dev
{"name":"licensingservice","profiles":["dev"],"label":null,"version":"95a673918f17f311f3159259bf57d95735741dab","state":null,"propertySources":[{"name":"https://github.com/michaelzhanghe/springcloud-config-repo/licensingservice/licensingservice-dev.yml","source":{"spring.jpa.database":"POSTGRESQL","spring.datasource.platform":"postgres","spring.jpa.show-sql":"false","spring.database.driverClassName":"org.postgresql.Driver","spring.datasource.url":"jdbc:postgresql://database:5432/eagle_eye_dev","spring.datasource.username":"postgres_dev","spring.datasource.testWhileIdle":"true","spring.datasource.validationQuery":"SELECT 1","spring.jpa.properties.hibernate.dialect":"org.hibernate.dialect.PostgreSQLDialect","redis.server":"redis","redis.port":"6379","signing.key":"345345fsdfsf5345","spring.datasource.password":"d495ce8603af958b2526967648aa9620b7e834c4eaff66014aa805450736e119"}},{"name":"https://github.com/michaelzhanghe/springcloud-config-repo/licensingservice/licensingservice.yml","source":{"example.property":"I AM IN THE DEFAULT","spring.jpa.database":"POSTGRESQL","spring.datasource.platform":"postgres","spring.jpa.show-sql":"true","spring.database.driverClassName":"org.postgresql.Driver","spring.datasource.url":"jdbc:postgresql://database:5432/eagle_eye_local","spring.datasource.username":"postgres","spring.datasource.testWhileIdle":"true","spring.datasource.validationQuery":"SELECT 1","spring.jpa.properties.hibernate.dialect":"org.hibernate.dialect.PostgreSQLDialect","redis.server":"redis","redis.port":"6379","signing.key":"345345fsdfsf5345","spring.datasource.password":"4788dfe1ccbe6485934aec2ffeddb06163ea3d616df5fd75be96aadd4df1da91"}}]}

michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ curl http://localhost:8888/licensingservice/default
{"name":"licensingservice","profiles":["default"],"label":null,"version":"95a673918f17f311f3159259bf57d95735741dab","state":null,"propertySources":[{"name":"https://github.com/michaelzhanghe/springcloud-config-repo/licensingservice/licensingservice.yml","source":{"example.property":"I AM IN THE DEFAULT","spring.jpa.database":"POSTGRESQL","spring.datasource.platform":"postgres","spring.jpa.show-sql":"true","spring.database.driverClassName":"org.postgresql.Driver","spring.datasource.url":"jdbc:postgresql://database:5432/eagle_eye_local","spring.datasource.username":"postgres","spring.datasource.testWhileIdle":"true","spring.datasource.validationQuery":"SELECT 1","spring.jpa.properties.hibernate.dialect":"org.hibernate.dialect.PostgreSQLDialect","redis.server":"redis","redis.port":"6379","signing.key":"345345fsdfsf5345","spring.datasource.password":"4788dfe1ccbe6485934aec2ffeddb06163ea3d616df5fd75be96aadd4df1da91"}}]}

michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ curl http://localhost:8888/licensingservice/prod
{"name":"licensingservice","profiles":["prod"],"label":null,"version":"95a673918f17f311f3159259bf57d95735741dab","state":null,"propertySources":[{"name":"https://github.com/michaelzhanghe/springcloud-config-repo/licensingservice/licensingservice-prod.yml","source":{"example.property":"I AM A PROD PROPERTY OVERRIDE","spring.jpa.database":"POSTGRESQL","spring.datasource.platform":"postgres","spring.jpa.show-sql":"true","spring.database.driverClassName":"org.postgresql.Driver","spring.datasource.url":"jdbc:postgresql://database:5432/eagle_eye_prod","spring.datasource.username":"postgres_prod","spring.datasource.testWhileIdle":"true","spring.datasource.validationQuery":"SELECT 1","spring.jpa.properties.hibernate.dialect":"org.hibernate.dialect.PostgreSQLDialect","redis.server":"redis","redis.port":"6379","signing.key":"345345fsdfsf5345","spring.datasource.password":"217b23d6209b10bd82c49a9df6490670052a9cd9d4403dcc1288db21c35c48ac"}},{"name":"https://github.com/michaelzhanghe/springcloud-config-repo/licensingservice/licensingservice.yml","source":{"example.property":"I AM IN THE DEFAULT","spring.jpa.database":"POSTGRESQL","spring.datasource.platform":"postgres","spring.jpa.show-sql":"true","spring.database.driverClassName":"org.postgresql.Driver","spring.datasource.url":"jdbc:postgresql://database:5432/eagle_eye_local","spring.datasource.username":"postgres","spring.datasource.testWhileIdle":"true","spring.datasource.validationQuery":"SELECT 1","spring.jpa.properties.hibernate.dialect":"org.hibernate.dialect.PostgreSQLDialect","redis.server":"redis","redis.port":"6379","signing.key":"345345fsdfsf5345","spring.datasource.password":"4788dfe1ccbe6485934aec2ffeddb06163ea3d616df5fd75be96aadd4df1da91"}}]}michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ 

michael01@michael01-ubuntu01:~/springcloudroot/springcloud-02-confsrv$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
d3138b4bc1b9        233b4584ad84        "/usr/bin/java -jar …"   5 minutes ago       Up 5 minutes        0.0.0.0:8888->8888/tcp   determined_turing


阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页