今天單獨使用SpringBoot,發現其中的bootstrap.properties文件無法生效,改成yaml格式也無濟於事。
最后調查發現原來是因為SpringBoot本身並不支持,需要和Spring Cloud 的組件結合——只有加上Spring Cloud Context依賴才能生效。
即在pom中引入:
<!--需要引入該jar才能使bootstrap配置文件生效--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-context</artifactId> </dependency>
問題解決。
