File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
main/java/org/springframework/context/annotation
test/java/org/springframework/context/annotation Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,8 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
311311 */
312312 private void processMemberClasses (ConfigurationClass configClass , SourceClass sourceClass ) throws IOException {
313313 for (SourceClass memberClass : sourceClass .getMemberClasses ()) {
314- if (ConfigurationClassUtils .isConfigurationCandidate (memberClass .getMetadata ())) {
314+ if (ConfigurationClassUtils .isConfigurationCandidate (memberClass .getMetadata ()) &&
315+ !memberClass .getMetadata ().getClassName ().equals (configClass .getMetadata ().getClassName ())) {
315316 processConfigurationClass (memberClass .asConfigClass (configClass ));
316317 }
317318 }
Original file line number Diff line number Diff line change 4141import org .springframework .beans .factory .support .DefaultListableBeanFactory ;
4242import org .springframework .context .annotation .ComponentScan .Filter ;
4343import org .springframework .context .annotation .ComponentScanParserTests .KustomAnnotationAutowiredBean ;
44+ import org .springframework .context .annotation .componentscan .simple .ClassWithNestedComponents ;
4445import org .springframework .context .annotation .componentscan .simple .SimpleComponent ;
4546import org .springframework .context .support .GenericApplicationContext ;
4647import org .springframework .tests .context .SimpleMapScope ;
@@ -115,6 +116,8 @@ public void viaContextRegistration_WithComposedAnnotation() {
115116 ctx .refresh ();
116117 ctx .getBean (ComposedAnnotationConfig .class );
117118 ctx .getBean (SimpleComponent .class );
119+ ctx .getBean (ClassWithNestedComponents .NestedComponent .class );
120+ ctx .getBean (ClassWithNestedComponents .OtherNestedComponent .class );
118121 assertThat ("config class bean not found" ,
119122 ctx .containsBeanDefinition ("componentScanAnnotationIntegrationTests.ComposedAnnotationConfig" ), is (true ));
120123 assertThat ("@ComponentScan annotated @Configuration class registered directly against " +
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2002-2014 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package org .springframework .context .annotation .componentscan .simple ;
18+
19+ import org .springframework .stereotype .Component ;
20+
21+ public class ClassWithNestedComponents {
22+
23+ @ Component
24+ public static class NestedComponent extends ClassWithNestedComponents {
25+ }
26+
27+ @ Component
28+ public static class OtherNestedComponent extends ClassWithNestedComponents {
29+ }
30+
31+ }
You can’t perform that action at this time.
0 commit comments