@@ -965,6 +965,7 @@ NOTE: DevTools relies on the application context's shutdown hook to close it dur
965
965
restart. It will not work correctly if you have disabled the shutdown hook (
966
966
`SpringApplication.setRegisterShutdownHook(false)`).
967
967
968
+ [[using-spring-boot-restart-vs-reload]]
968
969
.Restart vs Reload
969
970
****
970
971
The restart technology provided by Spring Boot works by using two classloaders.
@@ -975,12 +976,12 @@ and a new one is created. This approach means that application restarts are typi
975
976
faster than "`cold starts`" since the _base_ classloader is already available and
976
977
populated.
977
978
978
- If you find that restarts aren't quick enough for your applications, you could consider
979
- reloading technologies such as http://zeroturnaround.com/software/jrebel/[JRebel] from
980
- ZeroTurnaround. These work by rewriting classes as they are loaded to make them more
981
- amenable to reloading. https://github.com/spring-projects/spring-loaded[Spring Loaded]
982
- provides another option, however it doesn't support as many frameworks and it isn't
983
- commercially supported.
979
+ If you find that restarts aren't quick enough for your applications, or you encounter
980
+ classloading issues, you could consider reloading technologies such as
981
+ http://zeroturnaround.com/software/jrebel/[JRebel] from ZeroTurnaround. These work by
982
+ rewriting classes as they are loaded to make them more amenable to reloading.
983
+ https://github.com/spring-projects/spring-loaded[Spring Loaded] provides another option,
984
+ however it doesn't support as many frameworks and it isn't commercially supported.
984
985
****
985
986
986
987
@@ -1052,6 +1053,52 @@ in the same way.
1052
1053
1053
1054
1054
1055
1056
+ [[using-boot-devtools-customizing-classload]]
1057
+ ==== Customizing the restart classloader
1058
+ As described in the <<using-spring-boot-restart-vs-reload>> section above, restart
1059
+ functionality is implemented by using two classloaders. For most applications this
1060
+ approach works well, however, sometimes in can cause classloading issues.
1061
+
1062
+ By default, any open project in your IDE will be loaded using the "`restart`" classloader,
1063
+ and any regular `.jar` file will be loaded using the "`base`" classloader. If you work on
1064
+ a multi-module project, and not each module is imported into your IDE, you may need to
1065
+ customize things. To do this you can create a `META-INF/spring-devtools.properties` file.
1066
+
1067
+ The `spring-devtools.properties` file can contain `restart.exclude.` and
1068
+ `restart.include.` prefixed properties. The `include` elements are items that should be
1069
+ pulled-up into the "`restart`" classloader, and the `exclude` elements are items that
1070
+ should be pushed down into the "`base`" classloader. The value of the property is a regex
1071
+ pattern that will be applied to the classpath.
1072
+
1073
+ For example:
1074
+
1075
+ [source,properties,indent=0]
1076
+ ----
1077
+ restart.include.companycommonlibs=/mycorp-common-[\\w-]+\.jar
1078
+ restart.include.projectcommon=/mycorp-myproj-[\\w-]+\.jar
1079
+ ----
1080
+
1081
+ NOTE: All property keys must be unique. As long as a property starts with
1082
+ `restart.include.` or `restart.exclude.` it will be considered.
1083
+
1084
+ TIP: All `META-INF/spring-devtools.properties` from the classpath will be loaded. You can
1085
+ package files inside your project, or in the libraries that the project consumes.
1086
+
1087
+
1088
+
1089
+ [[using-boot-devtools-known-restart-limitations]]
1090
+ ==== Known limitations
1091
+ Restart functionality does not work well with objects that are deserialized using a
1092
+ standard `ObjectInputStream`. If you need to deserialize data, you may need to use Spring's
1093
+ `ConfigurableObjectInputStream` in combination with
1094
+ `Thread.currentThread().getContextClassLoader()`.
1095
+
1096
+ Unfortunately, several third-party libraries deserialize without considering the context
1097
+ classloader. If you find such a problem, you will need to request a fix with the original
1098
+ authors.
1099
+
1100
+
1101
+
1055
1102
[[using-boot-devtools-livereload]]
1056
1103
=== LiveReload
1057
1104
The `spring-boot-devtools` module includes an embedded LiveReload server that can be used
0 commit comments