Skip to content

Commit de04aa6

Browse files
committed
Make classloader customization easier to discover
If you encounter the problem of the two classloaders in Devtools, there's no hint that there are two classloaders and that some configuration changes might help you. You only get an IllegalArgumentException. Googling does not help because the exception is not mentioned in the docs. Futhermore, the docs sound like the problem can only occur in IDEs, which is not the case.
1 parent 2f7d62e commit de04aa6

File tree

1 file changed

+9
-1
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/using

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,18 @@ For IntelliJ IDEA, you can follow the https://www.jetbrains.com/help/idea/spring
217217
As described earlier in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders.
218218
For most applications, this approach works well.
219219
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+
----
220226

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

225233
The `spring-devtools.properties` file can contain properties prefixed with `restart.exclude` and `restart.include`.
226234
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.

0 commit comments

Comments
 (0)