我使用Spring Boot并且在bean实例化时遇到问题(他们创建了两次)。
如何在OQL查询中从bean引用中找到对ApplicationContext的引用?换句话说,找出给定bean的上下文。
PS VisualVM中的基本故障排除查询:
heap.objects("org.springframework.context.support.AbstractApplicationContext")
heap.objects("org.springframework.core.io.DefaultResourceLoader")
答案 0 :(得分:0)
按ApplicationContext
::
map(heap.objects("org.springframework.context.support.AbstractApplicationContext"), function(it) {
var fact = it.beanFactory;
var tbl = fact.singletonObjects.table;
var beans = map(filter(tbl, "it && /Step$/.test(it.key)"), "{key: it.key, val: it.val}");
return {ctx: it, beans: beans};
})
按ApplicationContext
::
map(heap.objects("org.springframework.context.support.AbstractApplicationContext"), function(it) {
var fact = it.beanFactory;
var tbl = fact.singletonObjects.table;
var beans = map(filter(tbl, "it && /^com.bigbrother/.test(classof(it.val).name)"), "{key: it.key, val: it.val}");
return {ctx: it, beans: beans};
})
如果Spring更改了底层实现,则应调整这些查询。寻找字段:
heap.objects("org.springframework.context.support.AbstractApplicationContext")