嘿, 如何處理Spring中的靜態初始化?我的意思是,我的bean有一個靜態的初始化Spring的靜態初始化
private static final Map<String, String> exceptionMapping = ErrorExceptionMapping.getExceptionMapping();
我需要注意ErrorExceptionMapping之前加載。我嘗試這樣做:
<bean id="errorExceptionMapping" class="cz.instance.transl.util.ErrorExceptionMapping" />
<bean id="validateService" class="cz.instance.transl.services.ValidateService" depends-on="errorExceptionMapping" >
但我得到
java.lang.NoClassDefFoundError: Could not initialize class cz.instance.transl.util.ErrorExceptionMapping
如果我省略了靜態初始化或從bean的方法中調用該方法,它當然很好。我想初始化回調(affterPropertiesSet())在這裏沒有幫助。
我試過了,看看中間粘貼的代碼,但它給了我的NoClassDefFoundError類。在這個班級裏有很多其他班級我不得不申報... – lisak 2010-11-22 16:54:14