Skip to content

Commit 243cf42

Browse files
committed
Incorporate change requests
1 parent 8bca439 commit 243cf42

File tree

1 file changed

+16
-14
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/using

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ 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. <<using#using.devtools.diagnosing-classloading-issues>> explains how to diagnose and solve them.
28+
2729
NOTE: Developer tools are automatically disabled when running a fully packaged application.
2830
If your application is launched from `java -jar` or if it is started from a special classloader, then it is considered a "`production application`".
2931
You can control this behavior by using the `spring.devtools.restart.enabled` system property.
@@ -40,6 +42,17 @@ When using the Gradle plugin, {spring-boot-gradle-plugin-docs}#packaging-executa
4042

4143

4244

45+
[[using.devtools.diagnosing-classloading-issues]]
46+
=== Diagnosing Classloading Issues
47+
48+
As described in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders.
49+
For most applications, this approach works well.
50+
However, it can sometimes cause classloading issues, in particular in multi-module projects.
51+
52+
To diagnose whether the classloading issues are indeed caused by devtools and its two classloaders, <<using#using.devtools.restart.disable,try disabling restart>>. If this solves your problems, <<using#using.devtools.restart.customizing-the-classload,customize the restart classloader>> to include your entire project.
53+
54+
55+
4356
[[using.devtools.property-defaults]]
4457
=== Property Defaults
4558
Several of the libraries supported by Spring Boot use caches to improve performance.
@@ -214,22 +227,11 @@ For IntelliJ IDEA, you can follow the https://www.jetbrains.com/help/idea/spring
214227

215228
[[using.devtools.restart.customizing-the-classload]]
216229
==== Customizing the Restart Classloader
217-
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.
220-
These might manifest in an exception like:
221-
222-
[source,text]
223-
----
224-
Caused by: java.lang.IllegalArgumentException: non-public interface is not defined by the given loader
225-
----
226-
227-
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.
228-
If you work on a multi-module project, and not every module is imported into your IDE, you may need to customize things.
229-
The same is true if you use `mvn spring-boot:run` or `gradle bootRun` in a multi-module project: The project containing your `@SpringBootApplication` is loaded with the "`restart`" classloader, and everything else with the "`base`" classloader.
230+
As described earlier in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders. If this causes issues, you might need to customize what gets loaded by which classloader.
230231

231-
To instruct Spring Boot to load `.jar` files with a different classloader, you can create a `META-INF/spring-devtools.properties` file.
232+
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. 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.
232233

234+
You can instruct Spring Boot to load parts of your project with a different classloader by creating a `META-INF/spring-devtools.properties` file.
233235
The `spring-devtools.properties` file can contain properties prefixed with `restart.exclude` and `restart.include`.
234236
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.
235237
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)