File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
spring-test/src/main/java/org/springframework/wx Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ public static void main(String[] args) {
6666// String value = expression.getValue(ctx,String.class);
6767// System.out.println(value);
6868
69+ // 测试importSelector
70+ AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext ("org.springframework.wx.importSelector" );
71+ annotationConfigApplicationContext .getBean ("personL" );
72+
6973
7074 }
7175
Original file line number Diff line number Diff line change 1+ package org .springframework .wx .importSelector ;
2+
3+ import org .springframework .context .annotation .Configuration ;
4+ import org .springframework .context .annotation .Import ;
5+ import org .springframework .context .annotation .ImportSelector ;
6+ import org .springframework .core .type .AnnotationMetadata ;
7+
8+ /**
9+ * @author wuxin
10+ * @date 2022/12/07 22:38:36
11+ */
12+ @ Import (MySelector .class )
13+ @ Configuration
14+ public class MySelector implements ImportSelector {
15+ @ Override
16+ public String [] selectImports (AnnotationMetadata importingClassMetadata ) {
17+ String [] classArray = {PersonL .class .getName ()};
18+ return classArray ;
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package org .springframework .wx .importSelector ;
2+
3+ /**
4+ * @author wuxin
5+ * @date 2022/12/07 22:41:47
6+ */
7+ public class PersonL {
8+ }
You can’t perform that action at this time.
0 commit comments