1. 程式人生 > >spring 裝配容器失敗- org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

spring 裝配容器失敗- org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

出現 rom fin exception and enum file 找到 encoding

問題1.

Context initialization failed

     org.springframework. beans.factory.xml.XmlBeanDefinitionStoreException:Line 1 in XML document from 
file [spring-wlf.xml] is invalid;nested exception is org.xml.sax.SAXParseException:The processing instruction
target matching "[xX][mM][1L]” is not allowed.

原因: spring.xml中的文件第一行出現空格:

 空格<?xml version="1.0" encoding="UTF-8"?>

解決: 刪除空格

問題2:

nested exception is og.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 47; cvc-elt.1: 找不到元素 ‘beans‘ 

原因: <bean 中的命名空間錯誤,

解決:

到本地的spring-beans.jar或者spring-content.jar中查找, 找到 spring-schemas中的命名空間。

然後復制相應的xmlns等命名空間到spring.xml 文件中。

spring 裝配容器失敗- org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException