-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
Description
Start off with the latest spring-petclinic project based on Boot 2.3.x
Launch the app and see the JSON response for /actuator/beans
Search for OwnerController bean. This bean should depend on OwnerRepository and PetRepository. The JSON for the bean however is this:
"ownerController": {
"aliases": [],
"scope": "singleton",
"type": "org.springframework.samples.petclinic.owner.OwnerController",
"resource": "file [/Users/aboyko/Documents/runtime-sts4/spring-petclinic/target/classes/org/springframework/samples/petclinic/owner/OwnerController.class]",
"dependencies": []
},
If spring-petclinic is switched to Boot 2.2.x then the dependencies are detected correctly:
"ownerController": {
"aliases": [],
"scope": "singleton",
"type": "org.springframework.samples.petclinic.owner.OwnerController",
"resource": "file [/Users/aboyko/Documents/runtime-sts4/spring-petclinic/target/classes/org/springframework/samples/petclinic/owner/OwnerController.class]",
"dependencies": [
"ownerRepository",
"visitRepository"
]
},
Something is off in the framework as actuator simply calls org.springframework.beans.factory.config.ConfigurableBeanFactory.getDependenciesForBean(String)
Try this in the org.springframework.samples.petclinic.PetClinicApplication for the main method:
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(PetClinicApplication.class, args);
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
final Runnable printDependnecies = new Runnable() {
public void run() {
String[] dependenciesForBean = context.getBeanFactory().getDependenciesForBean("ownerController");
if (dependenciesForBean.length == 0) {
System.out.println("no dependencies!!!");
} else {
System.out.println("Dependencies:");
for (String dep : dependenciesForBean) {
System.out.println(dep);
}
System.out.println();
}
}
};
scheduler.scheduleAtFixedRate(printDependnecies, 10, 10, TimeUnit.SECONDS);
}
You'd see that there are no dependencies returned in the Boot 2.3.x case.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug