I believe you are looking for the DevToolsEnablementDeducer
which determines if dev tools is enabled within a specific thread based off the current stack and what is excluded by default.
Also, when built as a jar the spring-boot-maven-plugin
will exclude the dependency if configured properly:
Devtools is automatically excluded by default (you can control that using the excludeDevtools property). In order to make that work with war packaging, the spring-boot-devtools dependency must be set as optional or with the provided scope.
Likewise, with gradle the recommended way of enabling also does not include when its packaged:
dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
}
This means that if you choose to still include the dependency into your produced jar, then dev tools will then activate based off the existing LocalDevToolsAutoConfiguration
which is loaded via the imports.