Spring Boot应用程序无法热插拔更改

时间:2018-09-27 12:44:29

标签: java spring spring-boot intellij-idea

我正在从事Spring Boot项目,因此我尝试将IDE从STS切换到Intellij CE。除了调试时,其他一切都正常。每当我更改Java类时,Spring都会尝试重新启动整个应用程序并失败,并显示以下消息:

web - 2018-09-27 08:39:18,494 [restartedMain] WARN  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xyz.service.IUserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
web - 2018-09-27 08:39:18,496 [restartedMain] INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
web - 2018-09-27 08:39:18,498 [restartedMain] INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat]
web - 2018-09-27 08:39:18,524 [restartedMain] INFO  o.s.b.a.l.AutoConfigurationReportLoggingInitializer - 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
web - 2018-09-27 08:39:18,871 [restartedMain] ERROR o.s.b.d.LoggingFailureAnalysisReporter - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field userService in com.xyz.controller.UserController required a bean of type 'com.xyz.service.IUserService' that could not be found.


Action:

Consider defining a bean of type 'com.xyz.service.IUserService' in your configuration.

以下是有关环境的背景信息:

  1. spring-boot-devtools 1.5.9依赖项已添加到我们的pom.xml
  2. 选中了“首选项->构建,执行,部署->编译器->自动构建项目”选项

  3. 我尝试使用选项“ cmd + shift + a-> Registry-> compiler.automake.allow.when.app.running”进行调试,并且未选中

  4. IDE版本为

    IDE version

  5. spring-boot-starter-parent版本是1.5.9.RELEASE

  6. 以下结构描述了类层次结构:

com.xyz
|-service
|  |-IUserService
|  |-impl
|     |-UserService
|-controller
   |-UserController
  1. UserService.java带有@ org.springframework.stereotype.Service
  2. 注释
  3. UserController具有以下字段:
    @Autowired
    private IUserService userService

我还尝试了this thread的所有答案,但未能解决问题。有人遇到过这个问题吗?预期的行为不是重新启动整个应用程序,而是仅热交换更改的工件。

编辑:

这是UserController示例:

if 'data' in cart_list_view

1 个答案:

答案 0 :(得分:0)

Spring Boot运行配置中有一个选项,可以在重新启动应用程序上下文之前尝试热插拔:

enter image description here

正确的触发文件选项将自动添加到命令行。