如何查看SpringBoot默认配置

问题

我们知道在使用spring-boot的时候,他会给我们使用很多默认配置。有时候我们需要看一下当前的配置情况。那么如何查看默认配置呢?

分析

1. 直接看代码

肯定可行,但是可能比较耗费时间。

2. 运行的时候直接输出来看一下

我们可以在springboot的官方文档中找到解决方案:

If you need to find out what auto-configuration is currently being applied, and why, start your application with the --debug switch. This will enable debug logs for a selection of core loggers and log an auto-configuration report to the console.

翻译一下就是:
如果你需要看一下当前默认配置使用的是什么、为什么使用,那么启动你应用的时候添加--debug 参数。这会启用debug日志,将自动配置报告打印到控制台。

解决

启动应用的时候加上--debug参数就可以了。


版权声明:本文为guanking19原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。