Skip to content

Commit 221e4b2

Browse files
authored
Merge pull request #46140 from mcruzdev/issue-45961
Spring DI - Fix behavior with named beans
2 parents 2df8c69 + 37dc798 commit 221e4b2

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

extensions/spring-di/deployment/src/main/java/io/quarkus/spring/di/deployment/SpringDIProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ private String getBeanNameFromBeanInstance(AnnotationInstance annotationInstance
526526
}
527527
if (beanName == null || beanName.isEmpty()) {
528528
final AnnotationValue beanValueAnnotationValue = annotationInstance.value();
529-
if (beanNameAnnotationValue != null) {
529+
if (beanValueAnnotationValue != null) {
530530
beanName = determineName(beanValueAnnotationValue);
531531
}
532532
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.quarkus.it.spring;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
public class MyConfigurationWithNamedBean {
8+
9+
@Bean("mySpecialName")
10+
public String foo() {
11+
return "foo";
12+
}
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.quarkus.it.spring;
2+
3+
import org.springframework.beans.factory.annotation.Qualifier;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class UseNamedBeanService {
8+
9+
String name;
10+
11+
public UseNamedBeanService(@Qualifier("mySpecialName") String name) {
12+
this.name = name;
13+
}
14+
15+
public String getName() {
16+
return name;
17+
}
18+
}

0 commit comments

Comments
 (0)