28
28
import org .apache .commons .logging .LogFactory ;
29
29
30
30
import org .springframework .beans .factory .InitializingBean ;
31
- import org .springframework .beans .factory .annotation . Autowired ;
31
+ import org .springframework .beans .factory .ObjectProvider ;
32
32
import org .springframework .beans .factory .annotation .Value ;
33
33
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
34
34
import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
@@ -131,20 +131,21 @@ private void logWarnings() {
131
131
@ ConditionalOnProperty (prefix = "spring.devtools.livereload" , name = "enabled" , matchIfMissing = true )
132
132
static class LiveReloadConfiguration {
133
133
134
- @ Autowired
135
- private DevToolsProperties properties ;
134
+ private final DevToolsProperties properties ;
136
135
137
- @ Autowired (required = false )
138
- private LiveReloadServer liveReloadServer ;
136
+ private final ClientHttpRequestFactory clientHttpRequestFactory ;
139
137
140
- @ Autowired
141
- private ClientHttpRequestFactory clientHttpRequestFactory ;
142
-
143
- @ Value ("${remoteUrl}" )
144
- private String remoteUrl ;
138
+ private final String remoteUrl ;
145
139
146
140
private ExecutorService executor = Executors .newSingleThreadExecutor ();
147
141
142
+ LiveReloadConfiguration (DevToolsProperties properties , ClientHttpRequestFactory clientHttpRequestFactory ,
143
+ @ Value ("${remoteUrl}" ) String remoteUrl ) {
144
+ this .properties = properties ;
145
+ this .clientHttpRequestFactory = clientHttpRequestFactory ;
146
+ this .remoteUrl = remoteUrl ;
147
+ }
148
+
148
149
@ Bean
149
150
@ RestartScope
150
151
@ ConditionalOnMissingBean
@@ -164,8 +165,8 @@ ApplicationListener<ClassPathChangedEvent> liveReloadTriggeringClassPathChangedE
164
165
}
165
166
166
167
@ Bean
167
- OptionalLiveReloadServer optionalLiveReloadServer () {
168
- return new OptionalLiveReloadServer (this . liveReloadServer );
168
+ OptionalLiveReloadServer optionalLiveReloadServer (ObjectProvider < LiveReloadServer > liveReloadServer ) {
169
+ return new OptionalLiveReloadServer (liveReloadServer . getIfAvailable () );
169
170
}
170
171
171
172
final ExecutorService getExecutor () {
@@ -181,11 +182,11 @@ final ExecutorService getExecutor() {
181
182
@ ConditionalOnProperty (prefix = "spring.devtools.remote.restart" , name = "enabled" , matchIfMissing = true )
182
183
static class RemoteRestartClientConfiguration {
183
184
184
- @ Autowired
185
- private DevToolsProperties properties ;
185
+ private final DevToolsProperties properties ;
186
186
187
- @ Value ("${remoteUrl}" )
188
- private String remoteUrl ;
187
+ RemoteRestartClientConfiguration (DevToolsProperties properties ) {
188
+ this .properties = properties ;
189
+ }
189
190
190
191
@ Bean
191
192
ClassPathFileSystemWatcher classPathFileSystemWatcher (FileSystemWatcherFactory fileSystemWatcherFactory ,
@@ -220,8 +221,9 @@ ClassPathRestartStrategy classPathRestartStrategy() {
220
221
}
221
222
222
223
@ Bean
223
- ClassPathChangeUploader classPathChangeUploader (ClientHttpRequestFactory requestFactory ) {
224
- String url = this .remoteUrl + this .properties .getRemote ().getContextPath () + "/restart" ;
224
+ ClassPathChangeUploader classPathChangeUploader (ClientHttpRequestFactory requestFactory ,
225
+ @ Value ("${remoteUrl}" ) String remoteUrl ) {
226
+ String url = remoteUrl + this .properties .getRemote ().getContextPath () + "/restart" ;
225
227
return new ClassPathChangeUploader (url , requestFactory );
226
228
}
227
229
0 commit comments