springmvc之JSR303驗證出現:警告: Exception encountered during context initialization - cancelling refresh at
阿新 • • 發佈:2018-11-11
昨晚在練習springmvc的JSR303資料驗證的時候,明明是跟著教程裡面走的,可是又出現了一個奇葩的問題:
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Cannot create inner bean '(inner bean)#296c6593' of type [org.springframework.web.bind.support.ConfigurableWebBindingInitializer] while setting bean property 'webBindingInitializer'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#296c6593': Cannot resolve reference to bean 'validator' while setting bean property 'validator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator' defined in class path resource [springmvc.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogger
一下是效果圖:
後面還有一大堆出不列出來了,昨晚搞了大半夜,今天搞了大半天都不行,後來一個道友建議我換一下jar包,我也只能死馬當活馬醫了,原來的springmvc的jar是4.3的,JSR303相關的jar包也是比較高版本的,我把所有的jar包換了一個低一點的版本以後,奇蹟出現了:
沒錯,我要驗證的就是輸入的時間是否是過去的時間。所以,如果你也遇到這樣的問題,在其他方法都不奏效以後,也可以試試將你的jar包改為低一些的版本試一試。