spring boot registry config 合并 尝试

pom.xml


	4.0.0

	com.test
	register
	0.0.1-SNAPSHOT
    war

	register
	http://maven.apache.org

	
		UTF-8
		UTF-8
		UTF-8
		UTF-8
		1.8
		com.template.RegisterApplication

	

	
		org.springframework.boot
		spring-boot-starter-parent
		2.0.5.RELEASE
		 
	

	

		
			org.springframework.cloud
			spring-cloud-starter-netflix-eureka-server
		

		
		
			org.springframework.boot
			spring-boot-starter-web
		
		
		
			org.springframework.boot
			spring-boot-starter-actuator
		

		
        
            org.springframework.cloud
            spring-cloud-config-server
        

		
			com.github.ulisesbocchio
			jasypt-spring-boot-starter
		
	


	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				${spring-cloud.version}
				pom
				import
			
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
				
					
						
							repackage
						
					
				
				
					${start-class}
					true
					true
				
			

			
				org.apache.maven.plugins
				maven-war-plugin
				${maven-war-plugin.version}
				
					false
				
			
		
	


  配置写在 bootstrap.yml 中,如果项目中有 applicaiton.yml 会被其他微服务 获取到, 造成配置文件覆盖。

spring:
    application:
        name: register
    profiles:
        active: dev
    cloud:
        config:
            server:
                git:
                    #git地址
                    uri: https://gitee.com/xxxxx/config
                    searchPaths: '{application}'
                    username: xxxxxx
                    password: xxxxxxx
                prefix: /config
                bootstrap: true
            fail-fast: true
            # name of the config server's property source (file.yml) that we want to use
            name: registry
            profile: dev # profile(s) of the property source
            label: master # toggle to switch to a different version of the configuration as stored in git
eureka 注册中心配置
eureka:
    instance:
        appname: registry
        instanceId: registry:${spring.application.instance_id:${random.value}}
        prefer-ip-address: true
        lease-renewal-interval-in-seconds: 5
        lease-expiration-duration-in-seconds: 10
        status-page-url-path: ${management.context-path}/info
        health-check-url-path: ${management.context-path}/health
        metadata-map:
            profile: ${spring.profiles.active}
            version: 3.0.1
    client:
        enabled: true
        fetch-registry: false
        register-with-eureka: false
        instance-info-replication-interval-seconds: 10
        registry-fetch-interval-seconds: 10
        service-url:
            defaultZone: http://admin:${security.user.password:admin}@localhost:${server.port}/eureka/
    server:
        # see discussion about enable-self-preservation:
        # https://github.com/jhipster/generator-jhipster/issues/3654
        enable-self-preservation: false
    dashboard:
        path: /registry

 

加一个启动类即可

 

测试:

 

http://localhost:8761/config/xxx-xx-dev.yml

xxx-xx 为项目名称 

 

参考:https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.0.RELEASE/single/spring-cloud-config.html

 

 

你可能感兴趣的:(spring boot registry config 合并 尝试)