@Autowired org.springframework.core.env.ConfigurableEnvironment environment; List<String> pss = StreamSupport.stream(environment.getPropertySources().spliterator(), false)
.filter(propertySource -> propertySource instanceof OriginTrackedMapPropertySource).map(propertySource -> propertySource.getName()).collect(Collectors.toList()); log.info("加載的配置文件有:" + new ObjectMapper().writeValueAsString(pss));
有時候發現配置項未生效,可能是當前應用使用的配置文件不對,上面代碼可以檢測運行的spring boot應用使用的配置文件具體是哪些。
