spring-cloud-config-server
其次,在所创建的Spring Boot程序的启动类上添加@EnableConfigServer注解,开启Config Server服务,代码如下:
@EnableConfigServer
@SpringBootApplication
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).
web(true).run(args);
}
}
最后,设置属性文件的位置。Spring Cloud Config提供本地存储配置的方式。在bootstrap启动属性文件中,设置属性spring.profiles.active=native,并且设置属性文件所在的位置,如下所示:
server:
port: 7788 #配置中心端口
spr Java开源项目【ali1024.coding.net/public/P7/Java/git】 ing:
application:
name: config-server #服务名称
profiles:
active: native #设置读取本地配置文件
cloud:
config:
server: native:
searchLocations: classpath:config/ #声明本地配置文件的存放位置
配置说明:
(1)spring.profiles.active=n