config server
< dependency>
< groupId> org.springframework.cloud</ groupId>
< artifactId> spring-cloud-starter-bus-amqp</ artifactId>
</ dependency>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-starter-actuator</ artifactId>
</ dependency>
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main ( String[ ] args) {
SpringApplication. run ( ConfigServerApplication. class , args) ;
}
}
三.在resoures下创建bootstrap.yml(比application.yml先加载)
spring :
application :
name : config- server
cloud :
config :
server :
git :
uri : https: //github.com/ydoublemm/spring- cloud- config- repo.git
rabbitmq :
host : your host address
port : port (default 5672)
username : your name
password : your password
management :
endpoints :
web :
exposure :
include : "*"
config client
< dependency>
< groupId> org.springframework.cloud</ groupId>
< artifactId> spring-cloud-starter-bus-amqp</ artifactId>
</ dependency>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-starter-actuator</ artifactId>
</ dependency>
@SpringBootApplication
public class ConfigClientApplication
{
public static void main ( String[ ] args ) {
SpringApplication. run ( ConfigClientApplication. class , args) ;
}
}
三.在resoures下创建bootstrap.yml(比application.yml先加载)
spring :
application :
name : application
cloud :
config :
discovery :
enabled : true
service-id : CONFIG- SERVER
profile : dev
management :
endpoints :
web :
exposure :
include : bus- refresh
spring :
rabbitmq :
host : your host address
port : port (default 5672)
username : your name
password : your password
四.启动项目 在git上修该配置后,打开cmd 输入 curl -X POST “localhost:8080/actuator/bus-refresh” 就能刷新配置了