spring經常找不到xsd
以前spring配置的時候,xsd都是直接用url連線的官網xsd
經常會出現因為網路問題導致的錯誤
錯誤如下
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractRefreshableConfigApplicationContext
網上查了資料後,發現可以讓spring直接讀取本地xsd
方法是匯入jar包org.springframework.context-3.0.1.RELEASE-A.jar
這個jar依賴org.springframework.beans-3.0.1.RELEASE-A.jar
spring-beans.jar(也就是上面的jar包,版本不一樣叫法不同)這個jar又需要依賴org.springframework.core-3.0.1.RELEASE-A.jar
同時還需要依賴org.springframework.expression-3.0.1.RELEASE-A.jar
也就是一共需要引入
spring-beans.jar
spring-core.jar
spring-expression.jar
spring.context.jar
spring的版本是3.0.1
不同版本可能需要引用的jar不完全一致,可以嘗試著引入其中一個,然後根據報錯去引用其他的jar包
如下報錯
java.lang.ClassNotFoundException: org.springframework.expression.PropertyAccessor
需要的就是spring-expression.jar