简体   繁体   English

使用带有显式配置的 Spring Boot

[英]Use Spring Boot with explicitly configuration

Is it possible to use Spring Boot so that all configurations are explicitly in the main class?是否可以使用 Spring Boot 以便所有配置都显式地在主类中?

For example, is it possible to tell spring-boot to print all autoconfigurations make by @SpringBootApplication so that I can copy paste in my main class?例如,是否可以告诉 spring-boot 打印由@SpringBootApplication 创建的所有自动配置,以便我可以在主类中复制粘贴?

Or is it possible to copy then from somewhere into the main?或者是否可以从某个地方复制到主文件中?

You can have Spring Boot create a report (a list of auto configurations) simply by enabling debug mode in your application.properties file:您只需在application.properties文件中启用调试模式,即可让 Spring Boot 创建报告(自动配置列表):

debug = true

The auto-configuration report contains information about the classes that Spring Boot found on the classpath and configured automatically.自动配置报告包含有关 Spring Boot 在类路径上找到并自动配置的类的信息。 It also shows information about classes that are known to Spring Boot but were not found on the classpath.它还显示有关 Spring Boot 已知但未在类路径中找到的类的信息。

And, because you've set debug=true in application.properties or application.yml , so you will see it in your output.而且,因为您已经在application.propertiesapplication.yml 中设置了debug=true ,所以您将在输出中看到它。

There is no way of doing this.没有办法做到这一点。 Either you embrace the devil and suffer the consequences latter if you need to personalize something unpredictable by spring boot developers or you don't use it's magic.如果您需要对 Spring Boot 开发人员无法预测的东西进行个性化处理,或者您不使用它的魔力,那么您要么接受魔鬼并承担后果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM