In my appllicaiton, I add SpringBoot devtools to improve the development speed.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
In its official document, it says
Developer tools are automatically disabled when running a fully packaged application. If your application is launched from java -jar or if it is started from a special classloader, then it is considered a “production application”.
The application is launched from java -jar in Production. But how is it lanched in Intellij idea while in development?
It's actually quite simple, but not obvious. When spring-boot-devtools is included on the classpath, then devtools is enabled.
By default the spring-boot-maven-plugin excludes spring-boot-devtools when building the final jar file, therefore it is disabled.
Spring Boot Maven Plugin docs:
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.
If you run your spring application from your IDE or run mvn spring-boot:run
spring-boot-devtools is in your classpath.
When spring-boot-devtools is running you will get a log similar to this:
.e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable