Break circular dependency in DevTools without using field injection
This commit is contained in:
parent
06cf698387
commit
d0f329caa4
|
@ -62,24 +62,12 @@ public class LocalDevToolsAutoConfiguration {
|
|||
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
|
||||
static class LiveReloadConfiguration {
|
||||
|
||||
private DevToolsProperties properties;
|
||||
|
||||
private LiveReloadServer liveReloadServer;
|
||||
|
||||
LiveReloadConfiguration(DevToolsProperties properties,
|
||||
ObjectProvider<LiveReloadServer> liveReloadServer) {
|
||||
this.properties = properties;
|
||||
LiveReloadConfiguration(ObjectProvider<LiveReloadServer> liveReloadServer) {
|
||||
this.liveReloadServer = liveReloadServer.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@RestartScope
|
||||
@ConditionalOnMissingBean
|
||||
public LiveReloadServer liveReloadServer() {
|
||||
return new LiveReloadServer(this.properties.getLivereload().getPort(),
|
||||
Restarter.getInstance().getThreadFactory());
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void onContextRefreshed(ContextRefreshedEvent event) {
|
||||
optionalLiveReloadServer().triggerReload();
|
||||
|
@ -97,6 +85,19 @@ public class LocalDevToolsAutoConfiguration {
|
|||
return new OptionalLiveReloadServer(this.liveReloadServer);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class LiveReloadServerConfiguration {
|
||||
|
||||
@Bean
|
||||
@RestartScope
|
||||
@ConditionalOnMissingBean
|
||||
public LiveReloadServer liveReloadServer(DevToolsProperties properties) {
|
||||
return new LiveReloadServer(properties.getLivereload().getPort(),
|
||||
Restarter.getInstance().getThreadFactory());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue