Skip to content

Commit 46ab60c

Browse files
committed
Merge branch '3.1.x' into 3.2.x
Closes gh-40607
2 parents 888ae04 + 3b7d477 commit 46ab60c

File tree

1 file changed

+7
-3
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/using

1 file changed

+7
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,24 @@ For IntelliJ IDEA, you can follow the https://www.jetbrains.com/help/idea/spring
229229
[[using.devtools.restart.customizing-the-classload]]
230230
==== Customizing the Restart Classloader
231231
As described earlier in the <<using#using.devtools.restart.restart-vs-reload>> section, restart functionality is implemented by using two classloaders.
232-
If this causes issues, you might need to customize what gets loaded by which classloader.
232+
If this causes issues, you can diagnose the problem by using the `spring.devtools.restart.enabled` system property, and if the app works with restart switched off, you might need to customize what gets loaded by which classloader.
233233

234234
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.
235235
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.
236+
The classpath is printed on the console when you start the app, which can help to identify any problematic entries.
237+
Classes used reflectively, especially annotations, can be loaded into the parent (fixed) classloader on startup before the application classes which uses them, and this might lead to them not being detected by Spring in the application.
236238

237239
You can instruct Spring Boot to load parts of your project with a different classloader by creating a `META-INF/spring-devtools.properties` file.
238240
The `spring-devtools.properties` file can contain properties prefixed with `restart.exclude` and `restart.include`.
239241
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.
240-
The value of the property is a regex pattern that is applied to the classpath, as shown in the following example:
242+
The value of the property is a regex pattern that is applied to the classpath passed to the JVM on startup.
243+
Here is an example where some local class files are excluded and some extra libraries are included in the restart class loader:
241244

242245
[source,yaml,indent=0,subs="verbatim",configblocks]
243246
----
244247
restart:
245248
exclude:
246-
companycommonlibs: "/mycorp-common-[\\w\\d-\\.]+\\.jar"
249+
companycommonlibs: "/mycorp-common-[\\w\\d-\\.]/(build|bin|out|target)/"
247250
include:
248251
projectcommon: "/mycorp-myproj-[\\w\\d-\\.]+\\.jar"
249252
----
@@ -253,6 +256,7 @@ As long as a property starts with `restart.include.` or `restart.exclude.` it is
253256

254257
TIP: All `META-INF/spring-devtools.properties` from the classpath are loaded.
255258
You can package files inside your project, or in the libraries that the project consumes.
259+
System properties can not be used, only the properties file.
256260

257261

258262

0 commit comments

Comments
 (0)