我正在从事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.
以下是有关环境的背景信息:
选中了“首选项->构建,执行,部署->编译器->自动构建项目”选项
我尝试使用选项“ cmd + shift + a-> Registry-> compiler.automake.allow.when.app.running”进行调试,并且未选中
IDE版本为
spring-boot-starter-parent版本是1.5.9.RELEASE
以下结构描述了类层次结构:
com.xyz |-service | |-IUserService | |-impl | |-UserService |-controller |-UserController
@Autowired private IUserService userService
我还尝试了this thread的所有答案,但未能解决问题。有人遇到过这个问题吗?预期的行为不是重新启动整个应用程序,而是仅热交换更改的工件。
编辑:
这是UserController示例:
if 'data' in cart_list_view