一、该问题的重现步骤是什么?
1. 新建一个Application
@EnableScheduling @SpringBootApplication() @ComponentScan(basePackageClasses = {"..."},basePackages = {"..."}) @MapperScan("..") public class ShopApplication { public static void main(String[] args) { BladeApplication.run("shopApplication", ShopApplication.class, args); }
2. 报如下错
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: A circular @Import has been detected: Illegal attempt by @Configuration class 'Application' to import class 'Application' as 'Application' is already present in the current import stack [Application->Application->ShopApplication] Offending resource: class path resource [org/springblade/Application.class] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:550) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:302) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:586) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:108) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:805) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_181] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:801) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.handle(ConfigurationClassParser.java:756) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:563) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:302) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:586) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:108) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:805) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_181] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:801) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:771) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE] at org.springblade.core.launch.BladeApplication.run(BladeApplication.java:50) [blade-core-launch-2.0.4.RELEASE.jar:na] at org.springblade.ShopApplication.main(ShopApplication.java:21) [classes/:na]
3.org.application.Application.class 是一个类,现在就是把SpringBladeX 模块化了。新建了一个模块就是上面的ShopApplication.class
下面是Application.class
@RunWith(SpringRunner.class) @EnableScheduling @SpringBootApplication() @ComponentScan(basePackages = {"..."},basePackageClasses = {"..."}) @MapperScan(basePackages = {"..."}) public class Application implements WebMvcConfigurer{ public static void main(String[] args) { BladeApplication.run(CommonConstant.APPLICATION_NAME, Application.class, args); } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new BotAuthTokenInterceptor()).addPathPatterns("/chatroom/**"); } }
二、你期待的结果是什么?实际看到的又是什么?
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
BladeX-Boot 2.0.5.RELEASE macOS
四、请提供详细的错误堆栈信息,这很重要。
五、若有更多详细信息,请在下面提供。
没模块化的时候,其实也报过一次这样的错(在你的库拉下来 没有任何修改的情况下),后来稀里糊涂就就没了这个错误. 那会我认为是环境的问题。然后也没问题了,就不管了。然后现在模块化再次出来这个问题。这个问题的根本原因,我估计是,启动的时候启动了Aplication.class 类。解决方法其实也简单,就是在ShopApplication 再加一个注解就好了,把Application.class 排除,禁用了就可以了,但是我比较想知道,为什么会去扫描这个Application.class 它们好像也没扫描关系啊。为什么会下面这个关系呢?
Application->Application->ShopApplication
就是这个关系很令我费解。(2个模块独立的,没有依赖关系) 下面是结构图
扫一扫访问 Blade技术社区 移动端