To use native configuration in the configuration center, you need to first introduce the dependency of the configuration center in pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
Then open the @EnableConfigServer annotation in the main program
@EnableConfigServer
@SpringBootApplication
public class ConfigApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigApplication.class, args);
}
}
Finally, configure the following in the yml configuration file:
#tomcat端口号
server.port=8080
#当spring.profiles.active的取值为native时,表明配置文件在本地
spring.profiles.active=native
#配置文件的目录,指定搜索的目录(如果没有上面一行的声明,则此行配置无效)
spring.cloud.config.server.native.search-locations=D:/config-file