新建一个config git 仓库 (可以使用github或开源中国的git仓库)
git@ubuntu:~/repo$ mkdir config.git
git@ubuntu:~/repo$ cd config.git
git@ubuntu:~/repo$ git --bare init
克隆config仓库
Administrator@WL /d/workspace
$ git clone http://192.168.245.128:8000/config.git
Cloning into 'config'...
Username for 'http://192.168.245.128:8000': git
Password for 'http://[email protected]:8000':
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
Administrator@WL /d/workspace
$ cd config/
Administrator@WL /d/workspace/config (master)
增加application.properties和blog.properties两个配置文件
Administrator@WL /d/workspace/config (master)
$ touch blog.properties
Administrator@WL /d/workspace/config (master)
$ touch application.properties
修改两个配置文件
application.properties如下
#env.host.db=172.20.62.86
env.host.db=127.0.0.1
env.host.mq=192.168.245.128
env.host.redis=192.168.245.128
#zookeeper
env.host.zookeeper=192.168.245.128
zookeeper.address=zookeeper://${env.host.zookeeper}:2181?timeout=20000
#=========================================================redis单机================================================
#########Redis 连接配置(spring.redis.host、spring.redis.port不同环境需要单独配置)
##Redis数据库索引(默认为0)
#spring.redis.database=0
##Redis服务器地址
spring.redis.host=${env.host.redis}
##Redis服务器连接端口
spring.redis.port=6380
blog.properties如下
logging.config=classpath:logger/logback-boot.xml
server.port=9002
#默认就是error
server.error.path=/error
#日期json
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=non_null
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
server.session.timeout=3600
因此前一进提交过application.properties所以现在只提交blog.properties
Administrator@WL /d/workspace/config (master)
$ git add blog.properties
Administrator@WL /d/workspace/config (master)
$ git commit -m 'add properties'
[master 4b431a5] add properties
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 blog.properties
Administrator@WL /d/workspace/config (master)
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'http://192.168.245.128:8000': git
Password for 'http://[email protected]:8000':
Counting objects: 4, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 312 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.245.128:8000/config.git
e5effec..4b431a5 master -> master
Administrator@WL /d/workspace/config (master)
$
新建config-service
spring-cloud-config-server服务器也是一个简单的spring-boot web服务器
新建maven工程
com.wl.config
config-service
1.0-SNAPSHOT
config-service
pom.xml(与其他spring-boot服务不同,需要依赖spring-cloud-config-server)
4.0.0
com.wl.config
config-service
1.0-SNAPSHOT
config-service
UTF-8
1.0-SNAPSHOT
com.wl.config.Application
1.5.7.RELEASE
1.2.2.RELEASE
1.7.5
2.4.5
4.12
2.4.5
1.1-groovy-2.4
org.springframework.boot
spring-boot-starter-web
${spring-boot-version}
org.slf4j
slf4j-api
org.springframework.cloud
spring-cloud-starter-config
${spring-cloud-starter-config-version}
com.fasterxml.jackson.core
jackson-databind
org.springframework.boot
*
org.springframework
spring-web
com.fasterxml.jackson.core
jackson-annotations
org.springframework.cloud
spring-cloud-config-server
${spring-cloud-starter-config-version}
org.slf4j
slf4j-api
${slf4j-api-version}
com.github.sgroschupf
zkclient
0.1
org.apache.zookeeper
zookeeper
log4j
log4j
org.codehaus.groovy
groovy-all
${groovy-all-version}
junit
junit
${junit.version}
test
org.spockframework
spock-core
${spock-core-version}
test
org.springframework.boot
spring-boot-starter-test
${spring-boot-version}
test
org.springframework.boot
spring-boot-autoconfigure
${spring-boot-version}
org.springframework.boot
spring-boot-maven-plugin
${spring-boot-version}
${MainClass}
JAR
repackage
org.apache.maven.plugins
maven-compiler-plugin
3.1
1.8
src/main/resources
**/*.*
*.*
src/main/java
**/*.*
*.*
application.properties配置
server.port=8888
spring.cloud.config.server.git.uri=http://192.168.245.128:8000/config.git
spring.cloud.config.server.git.password=123456
spring.cloud.config.server.git.username=git
启动类Application.java
package com.wl.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.config.server.EnableConfigServer;
/**
* Created by wl on 2019/3/7.
*/
@SpringBootApplication(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class //不使用数据库
},scanBasePackages = "com.wl")
@EnableConfigServer
public class Application {
private static final Logger logger = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setWebEnvironment(true);
app.run(args);
logger.info("application init success");
}
}
注意与一般的spring-boot服务启动类不同的时多了一个EnableConfigServer注解
启动服务
"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:58297,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\service\config-service\target\classes;D:\maven\repo\com\wl\common\daylife-api\1.0-SNAPSHOT\daylife-api-1.0-SNAPSHOT.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\1.5.7.RELEASE\spring-boot-starter-web-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\1.5.7.RELEASE\spring-boot-starter-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\1.5.7.RELEASE\spring-boot-starter-logging-1.5.7.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;D:\maven\repo\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;D:\maven\repo\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\1.5.7.RELEASE\spring-boot-starter-tomcat-1.5.7.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.20\tomcat-embed-core-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.20\tomcat-embed-el-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.20\tomcat-embed-websocket-8.5.20.jar;D:\maven\repo\org\hibernate\hibernate-validator\5.3.5.Final\hibernate-validator-5.3.5.Final.jar;D:\maven\repo\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\maven\repo\org\springframework\spring-web\4.3.11.RELEASE\spring-web-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\4.3.11.RELEASE\spring-webmvc-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-config\1.2.2.RELEASE\spring-cloud-starter-config-1.2.2.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\1.1.5.RELEASE\spring-cloud-starter-1.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\1.1.5.RELEASE\spring-cloud-context-1.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\1.1.5.RELEASE\spring-cloud-commons-1.1.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-client\1.2.2.RELEASE\spring-cloud-config-client-1.2.2.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-server\1.2.2.RELEASE\spring-cloud-config-server-1.2.2.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-actuator\1.4.1.RELEASE\spring-boot-starter-actuator-1.4.1.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-actuator\1.4.1.RELEASE\spring-boot-actuator-1.4.1.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\4.1.3.RELEASE\spring-security-crypto-4.1.3.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.3.RELEASE\spring-security-rsa-1.0.3.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.55\bcpkix-jdk15on-1.55.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.55\bcprov-jdk15on-1.55.jar;D:\maven\repo\org\eclipse\jgit\org.eclipse.jgit\3.5.3.201412180710-r\org.eclipse.jgit-3.5.3.201412180710-r.jar;D:\maven\repo\com\jcraft\jsch\0.1.50\jsch-0.1.50.jar;D:\maven\repo\com\googlecode\javaewah\JavaEWAH\0.7.9\JavaEWAH-0.7.9.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.1.3\httpclient-4.1.3.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.1.4\httpcore-4.1.4.jar;D:\maven\repo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;D:\maven\repo\commons-codec\commons-codec\1.4\commons-codec-1.4.jar;D:\maven\repo\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\maven\repo\com\github\sgroschupf\zkclient\0.1\zkclient-0.1.jar;D:\maven\repo\org\codehaus\groovy\groovy-all\2.4.5\groovy-all-2.4.5.jar;D:\maven\repo\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\1.5.7.RELEASE\spring-boot-autoconfigure-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\1.5.7.RELEASE\spring-boot-1.5.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.config.Application
Connected to the target VM, address: '127.0.0.1:58297', transport: 'socket'
2019-03-07 21:14:48.932 INFO 7412 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4659191b: startup date [Thu Mar 07 21:14:48 CST 2019]; root of context hierarchy
2019-03-07 21:14:49.103 INFO 7412 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$e9029dd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.7.RELEASE)
2019-03-07 21:14:50.394 INFO 7412 --- [ main] com.wl.config.Application : No active profile set, falling back to default profiles: default
2019-03-07 21:14:50.403 INFO 7412 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@51745f40: startup date [Thu Mar 07 21:14:50 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4659191b
2019-03-07 21:14:50.840 INFO 7412 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=e1f07989-d2f0-3920-a2ef-4b2f8e4f29a1
2019-03-07 21:14:50.896 INFO 7412 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$e9029dd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-07 21:14:51.153 INFO 7412 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8888 (http)
2019-03-07 21:14:51.158 INFO 7412 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-03-07 21:14:51.159 INFO 7412 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2019-03-07 21:14:51.228 INFO 7412 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-07 21:14:51.228 INFO 7412 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 825 ms
2019-03-07 21:14:51.390 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-07 21:14:51.393 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'metricsFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2019-03-07 21:14:51.394 INFO 7412 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2019-03-07 21:14:51.646 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@51745f40: startup date [Thu Mar 07 21:14:50 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4659191b
2019-03-07 21:14:51.688 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-07 21:14:51.689 INFO 7412 --- [ 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.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-07 21:14:51.694 INFO 7412 --- [ 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)
2019-03-07 21:14:51.694 INFO 7412 --- [ 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)
2019-03-07 21:14:51.694 INFO 7412 --- [ 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)
2019-03-07 21:14:51.694 INFO 7412 --- [ 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)
2019-03-07 21:14:51.695 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/encrypt/status],methods=[GET]}" onto public java.util.Map org.springframework.cloud.config.server.encryption.EncryptionController.status()
2019-03-07 21:14:51.695 INFO 7412 --- [ 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()
2019-03-07 21:14:51.695 INFO 7412 --- [ 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)
2019-03-07 21:14:51.699 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.config.server.environment.EnvironmentController.properties(java.lang.String,java.lang.String,boolean) throws java.io.IOException
2019-03-07 21:14:51.699 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.yml || /{name}-{profiles}.yaml],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.config.server.environment.EnvironmentController.yaml(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2019-03-07 21:14:51.700 INFO 7412 --- [ 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)
2019-03-07 21:14:51.700 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.properties],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.config.server.environment.EnvironmentController.labelledProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.io.IOException
2019-03-07 21:14:51.700 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{label}/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.config.server.environment.EnvironmentController.labelledJsonProperties(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2019-03-07 21:14:51.700 INFO 7412 --- [ 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 org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2019-03-07 21:14:51.700 INFO 7412 --- [ 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)
2019-03-07 21:14:51.701 INFO 7412 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/{name}-{profiles}.json],methods=[GET]}" onto public org.springframework.http.ResponseEntity org.springframework.cloud.config.server.environment.EnvironmentController.jsonProperties(java.lang.String,java.lang.String,boolean) throws java.lang.Exception
2019-03-07 21:14:51.702 INFO 7412 --- [ 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.resolve(java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest) throws java.io.IOException
2019-03-07 21:14:51.702 INFO 7412 --- [ 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
2019-03-07 21:14:51.725 INFO 7412 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 21:14:51.725 INFO 7412 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 21:14:51.765 INFO 7412 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-07 21:14:52.052 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.053 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.053 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.085 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.085 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.085 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.095 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.095 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.095 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.100 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.100 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.100 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.111 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.111 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.111 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/restart || /restart.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()
2019-03-07 21:14:52.112 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.112 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.112 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/refresh || /refresh.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2019-03-07 21:14:52.113 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.113 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
2019-03-07 21:14:52.114 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2019-03-07 21:14:52.114 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.114 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/pause || /pause.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2019-03-07 21:14:52.115 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2019-03-07 21:14:52.117 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2019-03-07 21:14:52.117 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.118 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.118 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.value(java.util.Map)
2019-03-07 21:14:52.118 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/reset],methods=[POST]}" onto public java.util.Map org.springframework.cloud.context.environment.EnvironmentManagerMvcEndpoint.reset()
2019-03-07 21:14:52.118 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2019-03-07 21:14:52.119 INFO 7412 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/resume || /resume.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()
2019-03-07 21:14:52.426 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-03-07 21:14:52.434 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-07 21:14:52.434 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshEndpoint' has been autodetected for JMX exposure
2019-03-07 21:14:52.434 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'restartEndpoint' has been autodetected for JMX exposure
2019-03-07 21:14:52.434 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-07 21:14:52.435 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-07 21:14:52.436 INFO 7412 --- [ 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]
2019-03-07 21:14:52.444 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'restartEndpoint': registering with JMX server as MBean [org.springframework.cloud.context.restart:name=restartEndpoint,type=RestartEndpoint]
2019-03-07 21:14:52.452 INFO 7412 --- [ 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]
2019-03-07 21:14:52.459 INFO 7412 --- [ 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=51745f40,type=ConfigurationPropertiesRebinder]
2019-03-07 21:14:52.463 INFO 7412 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2019-03-07 21:14:52.479 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.479 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.479 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.480 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.480 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.480 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$ResumeEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.485 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.486 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.486 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.487 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.487 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.487 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.518 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.518 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.518 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.519 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.519 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.519 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.context.restart.RestartEndpoint$PauseEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.525 WARN 7412 --- [ main] figurationPropertiesBindingPostProcessor : The @ConfigurationProperties bean class org.springframework.cloud.endpoint.RefreshEndpoint contains validation constraints but had not been annotated with @Validated.
2019-03-07 21:14:52.544 INFO 7412 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2019-03-07 21:14:52.659 INFO 7412 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8888 (http)
2019-03-07 21:14:52.662 INFO 7412 --- [ main] com.wl.config.Application : Started Application in 5.18 seconds (JVM running for 5.453)
2019-03-07 21:14:52.662 INFO 7412 --- [ main] com.wl.config.Application : application init success
在浏览器地址框输入http://localhost:8888/blog/default/master
结果如下。default为环境名 master为分支名。因为只有一个环境所以default修改为任何字符都是一样的
环境与文件命名规则相关譬如application-dev01.properties的配置文件应用名为application 环境名为dev01
{
"name": "blog",
"profiles": ["default"],
"label": "master",
"version": "c9b02a639cba3b5c8483868bd1d34af5fe1fed3c",
"state": null,
"propertySources": [{
"name": "http://192.168.245.128:8000/config.git/blog.properties",
"source": {
"server.error.path": "/error",
"server.port": "9002",
"spring.jackson.date-format": "yyyy-MM-dd HH:mm:ss",
"logging.config": "classpath:logger/logback-boot.xml",
"server.session.timeout": "3600",
"spring.jackson.time-zone": "GMT+8",
"spring.jackson.default-property-inclusion": "non_null"
}
}, {
"name": "http://192.168.245.128:8000/config.git/application.properties",
"source": {
"env.host.db": "127.0.0.1",
"zookeeper.address": "zookeeper://${env.host.zookeeper}:2181?timeout=20000",
"env.host.redis": "192.168.245.128",
"env.host.mq": "192.168.245.128",
"spring.redis.port": "6380",
"spring.redis.host": "${env.host.redis}",
"env.host.zookeeper": "192.168.245.128"
}
}]
}
上面是基于git的config服务。如果要使用基于文件系统的配置服务,需要修改config-service的配置文件application.properties
server.port=8888
#从classpath下config目录读取文件
#spring.cloud.config.server.native.searchLocations=classpath:/config
#从系统绝对路径读取配置文件 此目录是上面建的config git仓库本地目录
spring.cloud.config.server.native.searchLocations=file:///D:\\workspace\\wl\\study\\config
spring.profiles.active=native
我的config目录下的文件如下
Administrator@WL /d/workspace/wl/study/config (master)
$ ls
application.properties blog.properties config.iml
在浏览器输入http://localhost:8888/blog/default/master
{
"name": "blog",
"profiles": ["default"],
"label": "master",
"version": null,
"state": null,
"propertySources": [{
"name": "file:///D:/workspace/wl/study/config/blog.properties",
"source": {
"server.error.path": "/error",
"server.port": "9002",
"spring.jackson.date-format": "yyyy-MM-dd HH:mm:ss",
"logging.config": "classpath:logger/logback-boot.xml",
"server.session.timeout": "3600",
"spring.jackson.time-zone": "GMT+8",
"spring.jackson.default-property-inclusion": "non_null"
}
}, {
"name": "file:///D:/workspace/wl/study/config/application.properties",
"source": {
"env.host.db": "127.0.0.1",
"zookeeper.address": "zookeeper://${env.host.zookeeper}:2181?timeout=20000",
"env.host.redis": "192.168.245.128",
"env.host.mq": "192.168.245.128",
"spring.redis.port": "6380",
"spring.redis.host": "${env.host.redis}",
"env.host.zookeeper": "192.168.245.128"
}
}]
}
直接输入http://localhost:8888/blog-xxx.properties(XXX是环境名称)
Config支持我们使用的请求的参数规则为:
注意在分布式系统下文件要保持一致性。
上面的配置只能适用于一套环境 。
如果我们有多套环境,譬如dev01、dev02、dev03那么我们需要新建多个application-dev01.properties、application-dev02.properties、application-dev03.properties(blog.properties的配置不用改变只用改变application中的数据库、redis、mq等服务的地址,其他公共不变的配置可以放在application.properties中)(命名规则为应用名+"-" + 环境名+".properties" 或".yml")
譬如新增application-dev01.properties文件如下
application-dev01=application-dev01
浏览器输入http://localhost:8888/blog-dev01.properties
如下(会包含application.properties、application-dev01.properties、blog.properties的所有配置)
application-dev01: application-dev01
env.host.db: 127.0.0.1
env.host.mq: 192.168.245.128
env.host.redis: 192.168.245.128
env.host.zookeeper: 192.168.245.128
logging.config: classpath:logger/logback-boot.xml
server.error.path: /error
server.port: 9002
server.session.timeout: 3600
spring.jackson.date-format: yyyy-MM-dd HH:mm:ss
spring.jackson.default-property-inclusion: non_null
spring.jackson.time-zone: GMT+8
spring.redis.host: 192.168.245.128
spring.redis.port: 6380
zookeeper.address: zookeeper://192.168.245.128:2181?timeout=20000
在浏览器中输入 http://localhost:8888/blog/dev01
{
"name": "blog",
"profiles": ["dev01"],
"label": null,
"version": null,
"state": null,
"propertySources": [{
"name": "file:///D:/workspace/wl/study/config/application-dev01.properties",
"source": {
"application-dev01": "application-dev01"
}
}, {
"name": "file:///D:/workspace/wl/study/config/blog.properties",
"source": {
"server.error.path": "/error",
"server.port": "9002",
"spring.jackson.date-format": "yyyy-MM-dd HH:mm:ss",
"logging.config": "classpath:logger/logback-boot.xml",
"server.session.timeout": "3600",
"spring.jackson.time-zone": "GMT+8",
"spring.jackson.default-property-inclusion": "non_null"
}
}, {
"name": "file:///D:/workspace/wl/study/config/application.properties",
"source": {
"env.host.db": "127.0.0.1",
"zookeeper.address": "zookeeper://${env.host.zookeeper}:2181?timeout=20000",
"env.host.redis": "192.168.245.128",
"env.host.mq": "192.168.245.128",
"spring.redis.port": "6380",
"spring.redis.host": "${env.host.redis}",
"env.host.zookeeper": "192.168.245.128"
}
}]
}
下面介绍如何在其他spring-boot项目中加载配置服务器中的配置
首先新建工程blog
com.wl.blog
blog
1.0-SNAPSHOT
pom.xml
4.0.0
com.wl.blog
blog
1.0-SNAPSHOT
blog
UTF-8
1.0-SNAPSHOT
com.wl.blog.Application
1.5.7.RELEASE
1.4.5.RELEASE
1.4.5.RELEASE
1.7.5
org.springframework.boot
spring-boot-starter-web
${spring-boot-version}
org.slf4j
slf4j-api
org.springframework.boot
spring-boot-starter-data-redis
${spring-boot-version}
org.springframework.cloud
spring-cloud-starter-config
${spring-cloud-starter-config-version}
com.fasterxml.jackson.core
jackson-databind
org.springframework.boot
*
org.springframework
spring-web
com.fasterxml.jackson.core
jackson-annotations
org.slf4j
slf4j-api
${slf4j-api-version}
org.springframework.boot
spring-boot-starter-test
${spring-boot-version}
test
org.springframework.boot
spring-boot-autoconfigure
${spring-boot-version}
org.springframework.boot
spring-boot-maven-plugin
${spring-boot-version}
${MainClass}
JAR
repackage
org.apache.maven.plugins
maven-compiler-plugin
3.1
1.8
src/main/resources
**/*.*
*.*
src/main/java
**/*.*
*.*
bootstrap.properties
spring.application.name=blog
spring.cloud.config.uri=http://localhost:8888
#加载dev01环境的配置
spring.cloud.config.profile=dev01
#可以指定多个
spring.profiles.active[0]=dev01
#注意 spring.cloud.config.profile、spring.profiles.active可以只加入任意一个也可以都加这里我两个都加了
启动类
package com.wl.blog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.core.env.Environment;
/**
* Created by Administrator on 2019/3/11.
*/
@SpringBootApplication(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class //不使用数据库
},scanBasePackages = "com.wl")
public class Application implements CommandLineRunner{
private static final Logger logger = LoggerFactory.getLogger(Application.class);
@Autowired
private Environment environment;
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.setWebEnvironment(true);
app.run(args);
logger.info("application init success");
}
@Override
public void run(String... strings) throws Exception {
String str = environment.getProperty("application-dev01");
System.out.println(str);
}
}
启动日志
"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:60397,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\blog\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\1.5.7.RELEASE\spring-boot-starter-web-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\1.5.7.RELEASE\spring-boot-starter-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\1.5.7.RELEASE\spring-boot-starter-logging-1.5.7.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;D:\maven\repo\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;D:\maven\repo\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\1.5.7.RELEASE\spring-boot-starter-tomcat-1.5.7.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.20\tomcat-embed-core-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.20\tomcat-embed-el-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.20\tomcat-embed-websocket-8.5.20.jar;D:\maven\repo\org\hibernate\hibernate-validator\5.3.5.Final\hibernate-validator-5.3.5.Final.jar;D:\maven\repo\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\maven\repo\org\springframework\spring-web\4.3.11.RELEASE\spring-web-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\4.3.11.RELEASE\spring-webmvc-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-data-redis\1.5.7.RELEASE\spring-boot-starter-data-redis-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\data\spring-data-redis\1.8.7.RELEASE\spring-data-redis-1.8.7.RELEASE.jar;D:\maven\repo\org\springframework\data\spring-data-keyvalue\1.2.7.RELEASE\spring-data-keyvalue-1.2.7.RELEASE.jar;D:\maven\repo\org\springframework\data\spring-data-commons\1.13.7.RELEASE\spring-data-commons-1.13.7.RELEASE.jar;D:\maven\repo\org\springframework\spring-tx\4.3.11.RELEASE\spring-tx-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-oxm\4.3.11.RELEASE\spring-oxm-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-context-support\4.3.11.RELEASE\spring-context-support-4.3.11.RELEASE.jar;D:\maven\repo\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;D:\maven\repo\redis\clients\jedis\2.9.0\jedis-2.9.0.jar;D:\maven\repo\org\apache\commons\commons-pool2\2.4.2\commons-pool2-2.4.2.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-config\1.4.5.RELEASE\spring-cloud-starter-config-1.4.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter\1.3.5.RELEASE\spring-cloud-starter-1.3.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-context\1.3.5.RELEASE\spring-cloud-context-1.3.5.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-crypto\4.2.8.RELEASE\spring-security-crypto-4.2.8.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-commons\1.3.5.RELEASE\spring-cloud-commons-1.3.5.RELEASE.jar;D:\maven\repo\org\springframework\security\spring-security-rsa\1.0.3.RELEASE\spring-security-rsa-1.0.3.RELEASE.jar;D:\maven\repo\org\bouncycastle\bcpkix-jdk15on\1.55\bcpkix-jdk15on-1.55.jar;D:\maven\repo\org\bouncycastle\bcprov-jdk15on\1.55\bcprov-jdk15on-1.55.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-config-client\1.4.5.RELEASE\spring-cloud-config-client-1.4.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-eureka-client\1.4.5.RELEASE\spring-cloud-starter-netflix-eureka-client-1.4.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-core\1.4.5.RELEASE\spring-cloud-netflix-core-1.4.5.RELEASE.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-netflix-eureka-client\1.4.5.RELEASE\spring-cloud-netflix-eureka-client-1.4.5.RELEASE.jar;D:\maven\repo\com\netflix\eureka\eureka-client\1.7.2\eureka-client-1.7.2.jar;D:\maven\repo\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;D:\maven\repo\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;D:\maven\repo\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;D:\maven\repo\joda-time\joda-time\2.3\joda-time-2.3.jar;D:\maven\repo\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\maven\repo\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\maven\repo\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\maven\repo\com\google\code\gson\gson\2.1\gson-2.1.jar;D:\maven\repo\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;D:\maven\repo\com\netflix\archaius\archaius-core\0.7.5\archaius-core-0.7.5.jar;D:\maven\repo\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\maven\repo\com\netflix\servo\servo-core\0.10.1\servo-core-0.10.1.jar;D:\maven\repo\com\netflix\servo\servo-internal\0.10.1\servo-internal-0.10.1.jar;D:\maven\repo\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\maven\repo\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\maven\repo\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\maven\repo\org\apache\httpcomponents\httpclient\4.3.4\httpclient-4.3.4.jar;D:\maven\repo\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;D:\maven\repo\commons-codec\commons-codec\1.6\commons-codec-1.6.jar;D:\maven\repo\com\google\inject\guice\4.1.0\guice-4.1.0.jar;D:\maven\repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\maven\repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\maven\repo\com\netflix\eureka\eureka-core\1.7.2\eureka-core-1.7.2.jar;D:\maven\repo\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;D:\maven\repo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\maven\repo\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-archaius\1.4.5.RELEASE\spring-cloud-starter-netflix-archaius-1.4.5.RELEASE.jar;D:\maven\repo\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\maven\repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\maven\repo\com\google\guava\guava\18.0\guava-18.0.jar;D:\maven\repo\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\1.4.5.RELEASE\spring-cloud-starter-netflix-ribbon-1.4.5.RELEASE.jar;D:\maven\repo\com\netflix\ribbon\ribbon\2.2.5\ribbon-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-transport\2.2.5\ribbon-transport-2.2.5.jar;D:\maven\repo\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\maven\repo\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\maven\repo\com\netflix\hystrix\hystrix-core\1.4.3\hystrix-core-1.4.3.jar;D:\maven\repo\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\maven\repo\io\netty\netty-codec-http\4.0.27.Final\netty-codec-http-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-codec\4.0.27.Final\netty-codec-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-handler\4.0.27.Final\netty-handler-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-transport-native-epoll\4.0.27.Final\netty-transport-native-epoll-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-common\4.0.27.Final\netty-common-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-buffer\4.0.27.Final\netty-buffer-4.0.27.Final.jar;D:\maven\repo\io\netty\netty-transport\4.0.27.Final\netty-transport-4.0.27.Final.jar;D:\maven\repo\com\netflix\ribbon\ribbon-core\2.2.5\ribbon-core-2.2.5.jar;D:\maven\repo\com\netflix\ribbon\ribbon-httpclient\2.2.5\ribbon-httpclient-2.2.5.jar;D:\maven\repo\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;D:\maven\repo\com\netflix\ribbon\ribbon-loadbalancer\2.2.5\ribbon-loadbalancer-2.2.5.jar;D:\maven\repo\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\maven\repo\io\reactivex\rxjava\1.2.0\rxjava-1.2.0.jar;D:\maven\repo\com\netflix\ribbon\ribbon-eureka\2.2.5\ribbon-eureka-2.2.5.jar;D:\maven\repo\com\thoughtworks\xstream\xstream\1.4.10\xstream-1.4.10.jar;D:\maven\repo\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\maven\repo\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\maven\repo\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\1.5.7.RELEASE\spring-boot-autoconfigure-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\1.5.7.RELEASE\spring-boot-1.5.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.blog.Application
Connected to the target VM, address: '127.0.0.1:60397', transport: 'socket'
2019-03-11 22:35:03.911 INFO 4768 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7dfd3c81: startup date [Mon Mar 11 22:35:03 CST 2019]; root of context hierarchy
2019-03-11 22:35:04.126 INFO 4768 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 22:35:04.168 INFO 4768 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5a64d115] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.7.RELEASE)
2019-03-11 22:35:05.522 INFO 4768 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2019-03-11 22:35:06.748 INFO 4768 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=blog, profiles=[dev01], label=null, version=null, state=null
2019-03-11 22:35:06.749 INFO 4768 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource {name='file:///D:/workspace/wl/study/config/application-dev01.properties'}, MapPropertySource {name='file:///D:/workspace/wl/study/config/blog.properties'}, MapPropertySource {name='file:///D:/workspace/wl/study/config/application.properties'}]]
2019-03-11 22:35:06.750 WARN 4768 --- [ main] b.c.PropertySourceBootstrapConfiguration : Logging config file location 'classpath:logger/logback-boot.xml' cannot be opened and will be ignored
2019-03-11 22:35:06.752 INFO 4768 --- [ main] com.wl.blog.Application : The following profiles are active: dev01
2019-03-11 22:35:06.764 INFO 4768 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@34448e6c: startup date [Mon Mar 11 22:35:06 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@7dfd3c81
2019-03-11 22:35:07.237 INFO 4768 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-03-11 22:35:07.404 INFO 4768 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ac0c8a8d-dea0-34f7-99aa-4cfc5c047e2d
2019-03-11 22:35:07.414 INFO 4768 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-11 22:35:07.457 INFO 4768 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5a64d115] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-11 22:35:07.753 INFO 4768 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9002 (http)
2019-03-11 22:35:07.762 INFO 4768 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-03-11 22:35:07.763 INFO 4768 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2019-03-11 22:35:07.869 INFO 4768 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-11 22:35:07.869 INFO 4768 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1105 ms
2019-03-11 22:35:08.008 INFO 4768 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-11 22:35:08.012 INFO 4768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 22:35:08.013 INFO 4768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 22:35:08.013 INFO 4768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-11 22:35:08.013 INFO 4768 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-11 22:35:08.148 WARN 4768 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-03-11 22:35:08.149 INFO 4768 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-03-11 22:35:08.154 WARN 4768 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-03-11 22:35:08.154 INFO 4768 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-03-11 22:35:08.355 INFO 4768 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@34448e6c: startup date [Mon Mar 11 22:35:06 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@7dfd3c81
2019-03-11 22:35:08.408 INFO 4768 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-11 22:35:08.409 INFO 4768 --- [ 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.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-11 22:35:08.435 INFO 4768 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 22:35:08.435 INFO 4768 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 22:35:08.467 INFO 4768 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 22:35:09.739 INFO 4768 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-03-11 22:35:11.159 INFO 4768 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-03-11 22:35:11.361 INFO 4768 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-03-11 22:35:11.369 INFO 4768 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2019-03-11 22:35:11.369 INFO 4768 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2019-03-11 22:35:11.370 INFO 4768 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2019-03-11 22:35:11.372 INFO 4768 --- [ 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]
2019-03-11 22:35:11.382 INFO 4768 --- [ 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]
2019-03-11 22:35:11.391 INFO 4768 --- [ 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=34448e6c,type=ConfigurationPropertiesRebinder]
2019-03-11 22:35:11.402 INFO 4768 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2019-03-11 22:35:11.414 INFO 4768 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-03-11 22:35:11.448 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-03-11 22:35:11.649 INFO 4768 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-03-11 22:35:11.649 INFO 4768 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-03-11 22:35:11.771 INFO 4768 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-03-11 22:35:11.771 INFO 4768 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-03-11 22:35:11.953 INFO 4768 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-03-11 22:35:12.018 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-03-11 22:35:12.124 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-03-11 22:35:12.126 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-03-11 22:35:12.128 INFO 4768 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-03-11 22:35:12.130 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1552314912130 with initial instances count: 4
2019-03-11 22:35:12.133 INFO 4768 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application blog with eureka with status UP
2019-03-11 22:35:12.133 INFO 4768 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1552314912133, current=UP, previous=STARTING]
2019-03-11 22:35:12.135 INFO 4768 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_BLOG/localhost:blog:9002: registering service...
2019-03-11 22:35:12.161 INFO 4768 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_BLOG/localhost:blog:9002 - registration status: 204
2019-03-11 22:35:12.202 INFO 4768 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9002 (http)
2019-03-11 22:35:12.202 INFO 4768 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 9002
application-dev01
2019-03-11 22:35:17.109 INFO 4768 --- [ main] com.wl.blog.Application : Started Application in 14.632 seconds (JVM running for 14.989)
2019-03-11 22:35:17.109 INFO 4768 --- [ main] com.wl.blog.Application : application init success
获取到了application-dev01.properties中的配置
参考https://springcloud.cc/spring-cloud-config.html