【发布时间】:2019-11-29 17:57:23
【问题描述】:
我正在使用 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)来配置(我不能使用这个注解)。
基本上,我需要自己做(见下面的 devtools spring.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 不是特别流利)?
【问题讨论】:
标签: spring spring-boot spring-boot-devtools