-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
Tomasz Nurkiewicz opened SPR-8808 and commented
I am using AnnotationConfigWebApplicationContext and XML-free testing support with @ContextConfiguration(classes=...). When pointed @Configuration class contains @ComponentScan with a package containing that class:
package com.example.foo;
@Configuration
@ComponentScan(basePackages = "com.example.foo")
public class Config { }I get unexpected exception:
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'config' for bean class [com.example.foo.Config] conflicts with existing, non-compatible bean definition of same name and class [com.example.foo.Config]
While I understand why it happens, IMHO Spring should handle this case and simply ignore @Configuration found in scanned package if it has already been provided in AnnotationConfigWebApplicationContext.
Test case attached. On branch master you'll find a test case failing, branch fix fixes the problem by simply @Config to another package.
Affects: 3.1 RC1
Attachments:
- testcase2.zip (25.13 kB)
- testcase3.zip (29.18 kB)
Issue Links:
- Default @ComponentScan's exclude filter to exclude @Configuration annotated classes [SPR-8880] #13521 Default
@ComponentScan's exclude filter to exclude@Configurationannotated classes ("is duplicated by") - Allow recursive use of @ComponentScan [SPR-8307] #12956 Allow recursive use of
@ComponentScan
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement