Spring配置檔案中xsd版本號的問題
阿新 • • 發佈:2019-01-30
今天將以前的一個專案移植到新機器上開發,在原本的機器上跑得好好的專案移植過來之後報了個莫名其妙的錯:
在xml中給我說xsd的版本不對,於是將原本的如下程式碼片:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
之中的版本號統統去掉,使用本地jar中自帶的xsd版本,遂成功。
更改之後的程式碼如下:
如此,預設不使用網路上下載的xsd檔案,理論上較為優雅,且可以防止斷網時應用無法啟動、開源軟體更換域名時無法啟動、專案轉移時出現亂七八糟的問題等情況。xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">