Go to file
Chris Beams 6991cd9cdf Allow @Configuration classes to self-@ComponentScan
Prior to this change, a @Configuration classes that @ComponentScan
themselves would result in a ConflictingBeanDefinitionException.

For example:

    package com.foo.config;

    @Configuration
    @ComponentScan("com.foo");
    public class AppConfig {
        // ...
    }

This resulted in a ConflictingBeanDefinitionException that users have
typically worked around in the following fashion:

    package com.foo.config;

    @Configuration
    @ComponentScan(basePackages="com.foo",
        excludeFilters=@Filter(value=ANNOTATION_TYPE, type=Configuration.class);
    public class AppConfig {
        // ...
    }

This is obviously more verbose and cumbersome than would be desirable,
and furthermore potentially too constraining as it prohibits the ability
to include other legitimate @Configuration classes via scanning.

The exception was being thrown because of a logic problem in
ClassPathBeanDefinitionScanner.  The bean definition for AppConfig gets
registered once by the user (e.g. when constructing an
AnnotationConfigApplicationContext), then again when performing the
component scan for 'com.foo'. Prior to this change,
ClassPathBeanDefinitionScanner's #isCompatible returned false if the new
bean definition was anything other than an AnnotatedBeanDefinition.  The
intention of this check is really to see whether the new bean definition
is a *scanned* bean definition, i.e. the result of a component-scanning
operation.  If so, then it becomes safe to assume that the original bean
definition is the one that should be kept, as it is the one explicitly
registered by the user.

Therefore, the fix is as simple as narrowing the instanceof check from
AnnotatedBeanDefinition to its ScannedGenericBeanDefinition subtype.

Note that this commit partially reverts changes introduced in SPR-8307
that explicitly caught ConflictingBeanDefinitionExceptions when
processing recursive @ComponentScan definitions, and rethrew as a
"CircularComponentScanException.  With the changes in this commit,
such CBDEs will no longer occur, obviating the need for this check and
for this custom exception type altogether.

Issue: SPR-8808, SPR-8307
2011-11-28 21:35:38 +00:00
build-spring-framework SPR-8867 Fix issue with Content-Length header and UTF-8 charset. 2011-11-28 18:42:57 +00:00
org.springframework.aop Polish .aop copy of SpringConfiguredBDP 2011-11-28 06:57:04 +00:00
org.springframework.asm Merge 3.1.0 development branch into trunk 2010-10-25 19:48:20 +00:00
org.springframework.aspects + update aspectj cache aspects 2011-11-28 13:05:59 +00:00
org.springframework.beans fixed getAsText javadoc (SPR-7890) 2011-11-28 21:14:40 +00:00
org.springframework.context Allow @Configuration classes to self-@ComponentScan 2011-11-28 21:35:38 +00:00
org.springframework.context.support introduced JobDetail/CronTrigger/SimpleTriggerFactoryBean variants for Quartz 2.0/2.1 support (SPR-8275?) 2011-11-27 23:32:03 +00:00
org.springframework.core refined Resource "exists()" check for HTTP URLs to always return false for 404 status (SPR-7881) 2011-11-28 21:11:57 +00:00
org.springframework.expression polishing 2011-11-28 18:38:26 +00:00
org.springframework.instrument Include license.txt and notice.txt in module JARs 2011-02-09 06:56:40 +00:00
org.springframework.instrument.tomcat Include license.txt and notice.txt in module JARs 2011-02-09 06:56:40 +00:00
org.springframework.integration-tests Introduce @EnableCaching 2011-11-16 04:21:21 +00:00
org.springframework.jdbc Add Apache license header where missing in src/main 2011-11-16 18:23:56 +00:00
org.springframework.jms Corrected Javadoc: handleListenerException() and invokeErrorHandler() log at WARN level, not at ERROR level. 2011-10-10 22:13:45 +00:00
org.springframework.orm JPA EntityManagerFactoryUtils silently ignores IllegalArgumentExceptions from setHint calls (SPR-7947) 2011-11-28 20:54:37 +00:00
org.springframework.oxm [SPR-8222] Upgraded to JUnit 4.9. 2011-08-30 13:16:12 +00:00
org.springframework.spring-library Merge 3.1.0 development branch into trunk 2010-10-25 19:48:20 +00:00
org.springframework.spring-parent Fix JUnit version in spring-parent pom 2011-11-16 18:23:58 +00:00
org.springframework.test SimpleJdbcTestUtils executeSqlScript properly closes its LineNumberReader after use (SPR-8872) 2011-11-28 13:27:21 +00:00
org.springframework.transaction JDO PersistenceManager synchronization performs close attempt after completion (if necessary; SPR-8846) 2011-11-28 19:38:28 +00:00
org.springframework.web SPR-8867 Fix issue with Content-Length header and UTF-8 charset. 2011-11-28 18:42:57 +00:00
org.springframework.web.portlet Servlet/PortletContextResource's getFile prefers "file:" URL resolution over calling getRealPath (SPR-8461) 2011-11-28 16:51:42 +00:00
org.springframework.web.servlet fixed "formMultiSelect"/"formCheckboxes" FreeMarker macros to compare against actual field value (SPR-7721) 2011-11-28 14:42:03 +00:00
org.springframework.web.struts [SPR-8222] Upgraded to JUnit 4.9. 2011-08-30 13:16:12 +00:00
spring-framework-reference + update cache docs 2011-11-28 14:00:26 +00:00
.gitignore Add ignorable log file to .gitignore 2011-06-05 21:01:37 +00:00
build.properties Reorganize and add comments to build.properties 2011-08-20 03:02:05 +00:00
build.versions [SPR-8222] Upgraded to JUnit 4.9. 2011-08-30 13:16:12 +00:00
ci-build.properties adding properties file to simplify ant use in Bamboo CI build 2008-12-17 15:47:14 +00:00
eclipse-code-formatter.xml h2 embedded db support; updated formatting conventions not to auto-format javadoc; added hsqldb and h2 to jdbc maven pom as optional deps 2009-05-09 22:27:05 +00:00
spring-framework.ipr consistently use Unix line separator 2011-10-11 01:14:20 +00:00
spring-framework.psf Renamed org.springframework.instrument.classloading module to org.springframework.instrument.tomcat 2009-09-25 12:51:58 +00:00