@Bean definitions override scanned classes, plus check whether overriding is actually allowed

Issue: SPR-9567
Issue: SPR-9682
This commit is contained in:
Juergen Hoeller
2015-03-13 18:18:06 +01:00
parent 9d47a2b87e
commit 9d497cbd98
5 changed files with 68 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import example.scannable.FooService;
import example.scannable.MessageBean;
import example.scannable.ScopedProxyTestBean;
import example.scannable_implicitbasepackage.ComponentScanAnnotatedConfigWithImplicitBasePackage;
import example.scannable_implicitbasepackage.ConfigurableComponent;
import example.scannable_scoped.CustomScopeAnnotationBean;
import example.scannable_scoped.MyScope;
import org.junit.Test;
@@ -107,6 +108,7 @@ public class ComponentScanAnnotationIntegrationTests {
assertThat("@ComponentScan annotated @Configuration class registered directly against " +
"AnnotationConfigApplicationContext did not trigger component scanning as expected",
ctx.containsBean("scannedComponent"), is(true));
assertThat("@Bean method overrides scanned class", ctx.getBean(ConfigurableComponent.class).isFlag(), is(true));
}
@Test