I`m working on a Spring Boot project and I tried to switch our IDE from STS to Intellij CE. Everything is working fine except when debugging. Whenever I change a Java class, the Spring tries to restart the whole application and fail with the following message:
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.
Here is some context about the environment:
- The spring-boot-devtools 1.5.9 dependency is added to our pom.xml
The option "Preferences->Build, Execution, Deployment->Compiler->Build project automatically" is checked
I've tried debug with the option "cmd+shift+a->Registry->compiler.automake.allow.when.app.running" both checked and unchecked
The IDE version is
The spring-boot-starter-parent version is 1.5.9.RELEASE
The following structure describes the class hierarchy:
com.xyz |-service | |-IUserService | |-impl | |-UserService |-controller |-UserController
- UserService.java is annotated with @org.springframework.stereotype.Service
- UserController has the following field:
@Autowired private IUserService userService
Also, I've tried all the answers from this thread but didn't manage to solve the problem. Has anyone faced this issue? The expected behavior is not restart the whole application and hot swap only the changed artifacts.
Edit:
Here's the UserController sample:
@org.springframework.web.bind.annotation.RestController
@RequestMapping(value = "/user", produces = MediaType.APPLICATION_JSON_VALUE)
public class UserController{
@Autowired
private IUserService userService;
...
}