How can I tell whether my Spring boot application is in debug mode?
问题 I'd like to modify how my application works depending on whether the --debug switch is present or not. I tried this in my @Configuration file: @Value("\${debug}") lateinit var debug: String but Spring says Could not resolve placeholder 'debug' in value "${debug}" How can I query the state of the --debug option? 回答1: The most robust way to check for debug mode is to query the Environment . This will allow you to detect that the mode has been enabled whether that's been done via a command line