Skip to content

Commit 3a65d7b

Browse files
committed
Merge branch '2.7.x'
2 parents e691cfd + 19e671d commit 3a65d7b

File tree

1 file changed

+18
-4
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/using

1 file changed

+18
-4
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/devtools.adoc

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ To include devtools support, add the module dependency to your build, as shown i
2424
}
2525
----
2626

27+
CAUTION: Devtools might cause classloading issues, in particular in multi-module projects.
28+
<<using#using.devtools.diagnosing-classloading-issues>> explains how to diagnose and solve them.
29+
2730
NOTE: Developer tools are automatically disabled when running a fully packaged application.
2831
If your application is launched from `java -jar` or if it is started from a special classloader, then it is considered a "`production application`".
2932
You can control this behavior by using the `spring.devtools.restart.enabled` system property.
@@ -40,6 +43,18 @@ When using the Gradle plugin, {spring-boot-gradle-plugin-docs}#packaging-executa
4043

4144

4245

46+
[[using.devtools.diagnosing-classloading-issues]]
47+
=== Diagnosing Classloading Issues
48+
49+
As described in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders.
50+
For most applications, this approach works well.
51+
However, it can sometimes cause classloading issues, in particular in multi-module projects.
52+
53+
To diagnose whether the classloading issues are indeed caused by devtools and its two classloaders, <<using#using.devtools.restart.disable,try disabling restart>>.
54+
If this solves your problems, <<using#using.devtools.restart.customizing-the-classload,customize the restart classloader>> to include your entire project.
55+
56+
57+
4358
[[using.devtools.property-defaults]]
4459
=== Property Defaults
4560
Several of the libraries supported by Spring Boot use caches to improve performance.
@@ -215,13 +230,12 @@ For IntelliJ IDEA, you can follow the https://www.jetbrains.com/help/idea/spring
215230
[[using.devtools.restart.customizing-the-classload]]
216231
==== Customizing the Restart Classloader
217232
As described earlier in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders.
218-
For most applications, this approach works well.
219-
However, it can sometimes cause classloading issues.
233+
If this causes issues, you might need to customize what gets loaded by which classloader.
220234

221235
By default, any open project in your IDE is loaded with the "`restart`" classloader, and any regular `.jar` file is loaded with the "`base`" classloader.
222-
If you work on a multi-module project, and not every module is imported into your IDE, you may need to customize things.
223-
To do so, you can create a `META-INF/spring-devtools.properties` file.
236+
The same is true if you use `mvn spring-boot:run` or `gradle bootRun`: the project containing your `@SpringBootApplication` is loaded with the "`restart`" classloader, and everything else with the "`base`" classloader.
224237

238+
You can instruct Spring Boot to load parts of your project with a different classloader by creating a `META-INF/spring-devtools.properties` file.
225239
The `spring-devtools.properties` file can contain properties prefixed with `restart.exclude` and `restart.include`.
226240
The `include` elements are items that should be pulled up into the "`restart`" classloader, and the `exclude` elements are items that should be pushed down into the "`base`" classloader.
227241
The value of the property is a regex pattern that is applied to the classpath, as shown in the following example:

0 commit comments

Comments
 (0)