如何查看当前spring boot应用的配置文件


@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应用使用的配置文件具体是哪些。

posted on 2021-05-06 10:02  mylittlecabin  阅读(1143)  评论(0编辑  收藏  举报

导航