我正在使用 spring-boot v1.3.5.RELEASE 开发一个应用程序,它不使用@SpringBootApplication
也不@EnableAutconfiguration
(客户要求)。
我想spring-boot-devtools
在我的 IDE 中启用“重启”功能。我把它作为依赖,打mvn spring-boot:run
。重启器工作:
DEBUG o.s.b.d.r.Restarter - Creating new Restarter for thread Thread[main,5,main]
DEBUG o.s.b.d.r.Restarter - Immediately restarting application
DEBUG o.s.b.d.r.Restarter - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@22843e39
DEBUG o.s.b.d.r.Restarter - Starting application application.Application with URLs [file:/D:/git/repos/...]
但是在 IDE 代码修改和 rebluid 后它不会重新加载(在 eclipse 上按 Ctrl+B)。
问题似乎是 devtools 依赖于@EnableAutconfiguration
(加载了 的工厂META-INF/spring.factories
)进行配置(我不能使用这个注释)。基本上,我需要自己做(见下面的 devtoolsspring.factories
文件的内容):
# Application Initializers
org.springframework.context.ApplicationContextInitializer=\
org.springframework.boot.devtools.restart.RestartScopeInitializer
# Application Listeners
org.springframework.context.ApplicationListener=\
org.springframework.boot.devtools.restart.RestartApplicationListener
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration,\
org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration,\
org.springframework.boot.devtools.autoconfigure.RemoteDevToolsAutoConfiguration
# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.devtools.env.DevToolsHomePropertiesPostProcessor,\
org.springframework.boot.devtools.env.DevToolsPropertyDefaultsPostProcessor
# Restart Listeners
org.springframework.boot.devtools.restart.RestartListener=\
org.springframework.boot.devtools.log4j2.Log4J2RestartListener
我该怎么做(我对spring-boot lingua不是特别流利)?