File tree 4 files changed +99
-1
lines changed
spring-context/src/test/java/org/springframework/context/annotation
4 files changed +99
-1
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
42
42
43
43
import org .springframework .beans .factory .annotation .AnnotatedGenericBeanDefinition ;
44
44
import org .springframework .beans .factory .config .BeanDefinition ;
45
+ import org .springframework .context .annotation .componentscan .gh24375 .MyComponent ;
45
46
import org .springframework .context .index .CandidateComponentsTestClassLoader ;
46
47
import org .springframework .core .env .ConfigurableEnvironment ;
47
48
import org .springframework .core .env .StandardEnvironment ;
@@ -501,6 +502,15 @@ public void testIntegrationWithAnnotationConfigApplicationContext_metaProfile()
501
502
}
502
503
}
503
504
505
+ @ Test
506
+ public void gh24375 () {
507
+ ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider (true );
508
+ Set <BeanDefinition > components = provider .findCandidateComponents (MyComponent .class .getPackage ().getName ());
509
+ assertEquals (1 , components .size ());
510
+ assertEquals (MyComponent .class .getName (), components .iterator ().next ().getBeanClassName ());
511
+ }
512
+
513
+
504
514
private boolean containsBeanClass (Set <BeanDefinition > candidates , Class <?> beanClass ) {
505
515
for (BeanDefinition candidate : candidates ) {
506
516
if (beanClass .getName ().equals (candidate .getBeanClassName ())) {
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2002-2020 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
+ * https://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 .gh24375 ;
18
+
19
+ import java .lang .annotation .ElementType ;
20
+ import java .lang .annotation .Retention ;
21
+ import java .lang .annotation .RetentionPolicy ;
22
+ import java .lang .annotation .Target ;
23
+
24
+ import org .springframework .core .annotation .AliasFor ;
25
+
26
+ @ Target (ElementType .TYPE )
27
+ @ Retention (RetentionPolicy .RUNTIME )
28
+ public @interface A {
29
+
30
+ @ AliasFor ("value" )
31
+ B other () default @ B ;
32
+
33
+ @ AliasFor ("other" )
34
+ B value () default @ B ;
35
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2002-2020 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
+ * https://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 .gh24375 ;
18
+
19
+ import java .lang .annotation .ElementType ;
20
+ import java .lang .annotation .Retention ;
21
+ import java .lang .annotation .RetentionPolicy ;
22
+ import java .lang .annotation .Target ;
23
+
24
+ @ Target (ElementType .ANNOTATION_TYPE )
25
+ @ Retention (RetentionPolicy .RUNTIME )
26
+ public @interface B {
27
+
28
+ String name () default "" ;
29
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2002-2020 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
+ * https://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 .gh24375 ;
18
+
19
+ import org .springframework .stereotype .Component ;
20
+
21
+ @ Component
22
+ @ A (other = @ B )
23
+ public class MyComponent {
24
+ }
You can’t perform that action at this time.
0 commit comments