有没有诊断Spring bean/服务创建问题的好方法? [英] Is there a good way to diagnose spring bean/service creation problem?
问题描述
我的项目使用spring和spring-dm进行bean/服务配置.当我尝试导入一个也使用spring进行DI的旧项目时,将不会创建bean.
My project uses spring and spring-dm for bean/service configuration. When I try to import an old project which also use spring for DI, bean will not be created.
一个清楚的例子,
我首先在spring-appContext.xml中定义一个URL别名
I first define a url-alias in spring-appContext.xml
<bean name="xxxx" class="XRegistry" init-method="init">
<property name="webRoot" value="/WebContent"></property>
<property name="alias" value="/test"></property>
<property name="cAliasPattern" value="/test/*.do" />
<property name="conConfigFile" value="ddd.xml"/>
</bean>
在ddd.xml中,我定义了一些带有/test/abc.do之类的URL的控制器bean
in ddd.xml, I define some controller bean with url like /test/abc.do
在eclipse中作为OSGi框架启动时,不会发生任何错误. 但是当我尝试访问URL(/test/abc.do)时,遇到了"未知的OSGi URL :".
No errors occur when launching as OSGi framework in eclipse. But when I try to access the URL(/test/abc.do),"Unknown OSGi URL:" is met.
这个问题确实让我感到困惑,因为我不清楚从哪里开始.我的捆绑包依赖于Spring捆绑包,并具有appContext.xml和dispatcher.xml.只是正常的春季使用情况.
The problem really confuses me is I am not clear where to start. My bundle has depended on spring bundles and have appContext.xml and dispatcher.xml. Just a normal spring usage scenario.
由于春天对我来说就像黑匣子,我只能尝试一些我能想到的其他可能原因,但到目前为止还没有解决.有人知道如何监控春季启动过程或有用的日志吗?
As spring looks like black box to me, I can only try some other possible reasons I can think, but haven't fixed it till now. Is somebody know how to moniter the spring startup process or helpful logs?
谢谢.
编辑,当使用spring-dm时,需要创建一个包括log4j.properties的新片段来启用日志记录.这可以帮助您跟踪弹簧启动错误.
Edit when using spring-dm, you need to create a new fragment including log4j.properties to enable logging. This can help u to track spring startuping error.
正如我在第一个答案中所解释的,找到了根本原因,两种选择,
As I explain in the 1st answer, the root cause is found, two choice,
- 对于那些捆绑包同时存在于工作空间和目标平台中,请增加当前工作空间中捆绑软件的版本.当发生错误时,您还应该查看依赖项捆绑包
- 删除目标平台中的高版本捆绑软件.
推荐答案
您是否尝试过设置要调试的spring框架的日志级别?
Have you tried setting the log level for the spring framework to debug?
例如
log4j.rootLogger=WARN, stdout
[...]
log4j.logger.org.springframework=DEBUG
这始终是我尝试诊断bean创建问题时的第一个起点.
This is always my first starting point when trying to diagnose problems with bean creation.
这篇关于有没有诊断Spring bean/服务创建问题的好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!