1. 程式人生 > >spring載入beans找不到宣告

spring載入beans找不到宣告


Spring配置檔案xsi:schemaLocation無法解析導致啟動失敗的解決方案 

今天向伺服器部署一個console java app之後,啟動時發現程式出現異常: 
Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [app-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’. 
然後去看看app-config.xml裡的schema宣告部分,是這樣寫的: 
<beans xmlns=”http://www.springframework.org/schema/beans” 
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” 
xmlns:context=”http://www.springframework.org/schema/context” 
xsi:schemaLocation=”http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd” > 
很明顯,有關’beans’的宣告都放在http://www.springframework.org/schema/beans/spring-beans-3.0.xsd裡面了。可能是網路原因,訪問不倒導致解析app-config.xml失敗,致使程式丟擲異常。 
開啟spring-beans-3.0.1.RELEASE.jar一看,那個xsd檔案就在org.springframework.beans.factory.xml包下面,這下子好辦了,把xsd檔案的引用全改為本地的就行了: 
<beans xmlns=”http://www.springframework.org/schema/beans” 
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” 
xmlns:context=”http://www.springframework.org/schema/context” 
xsi:schemaLocation=”http://www.springframework.org/schema/beans 
classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
classpath:/org/springframework/context/config/spring-context-3.0.xsd” > 

相關推薦

spring載入beans宣告

Spring配置檔案xsi:schemaLocation無法解析導致啟動失敗的解決方案  今天向伺服器部署一個console java app之後,啟動時發現程式出現異常:  Exception in thread “main” org.springframework.beans.factory.xml.X

spring tool suite 到或者載入時異常! 無法編譯java檔案。

sts預設使用的是jre,如果編譯檔案需要使用jdk! 點選preferences --> java ----> lnstalled JREs 選擇jdk! jdk和jre區別 JDK,開發java程式用的開發包,JDK裡面有jav

maven 搭建spring框架報到applicationContext-*.xml文件

lte 重新 ID -- 直接 dao 成了 war包 config 問題原因: 早使用maven搭建web工程時,並沒有進行分布式搭建,我是把pojo、dao、service、web 四層直接放在了一個父工程中,並沒有一個一個的子工程區分,而是直接打包成了一個war包

關於spring配置檔案到xsd檔案的解決辦法

最近在搭建dubbo+zookeeper,在配置配置檔案的時候遇到這個問題:    cvc-complex-type.2.4.c: 萬用字元的匹配很全面, 但無法找到元素 'dubbo:application' 的宣告。 根據錯誤提示,有可能是http://code.

Spring Junit測試到SpringJUnit4ClassRunner.class

目錄 一、問題描述 1.當使用Junit指定啟動類為SpringJUnit4ClassRunner.class,發現SpringJUnit4ClassRunner.class找不到 2.

C# 無法載入 DLL 到指定的模組 (異常來自HRESULT:0x8007007E)的幾種可能情況

1.DLL引用丟失,或未將該DLL相關的DLL放在檔案的目錄下 2.當前選擇的是x64平臺,而DLL只支援x86 3.DLL是C++寫的,電腦未安裝VC執行時庫 4.未配置環境變數

Spring AOP schema到報錯 原

轉自:https://my.oschina.net/zetaplusae/blog/144821 使用jersey+spring構建RESTful服務,並將應用部署在不能連線外網的伺服器上。部署時,報錯資訊如下,   WARNING: Ignored XML validation warnin

spring 中類到總結java.lang.ClassNotFoundException

(1)org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'    

META-INF/spring.factories中到自動配置類,No auto configuration classes found in META-INF/spring.factories.

ERROR org.springframework.boot.SpringApplication - Application startup failed org.springframework.beans.factory.BeanDefinitionStoreExcepti

建立web工程Spring配置檔案到問題解決方案

2017-11-18 17:09:24 org.apache.catalina.core.StandardContext listenerStart嚴重: Exception sending context initialized event to listener in

java.lang.ClassNotFoundException web專案載入到類

1.概述作為一個屌絲程式猿,怎麼能不會配置log4j呢,這樣在控制檯或者日誌檔案中很容易找到程式出BUG的地方。尤其是在控制檯輸出日誌的時候,那叫一個爽啊!=-=  但是出現了問題,我擦,啟動web的時

xilinx載入電纜到的問題解決

Disconnect the Xilinx USB cable. Alternatively, you can disabled the USB cable in the device manager first then re-enable them in step 5; in this case, you

spring整合hibernate的時候資料來源配置了,hiberate 能夠連線資料,但是spring卻包到驅動啊

log4j:ERROR Failed to load driver java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriverat java.net.URLClassLoader.findClass(U

java.lang.ClassNotFoundException web專案載入到類

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xm

tomcat類載入到jar包中的類問題分析與解決思路

我們忽略了tomcat內部自定義的類載入器只想到了JVM的那幾個載入器,tomcat有個叫webApp的載入器它是先載入WEB-INF/classes後在載入WEB-INF/lib,但它的父載入器是它的common載入器,comon的父載入器是system載入器(和JVM的應用程式載入器功能差不多,不過指定了

系統啟動時,spring配置檔案解析失敗,報”cvc-elt.1: 到元素 'beans' 的宣告“異常

轉自: http://blog.163.com/[email protected]/blog/static/86556803201342210243656/ 現象:Tomcat啟動時,spring載入配置檔案applicationContext.xml出錯,丟

Spring到 “beans”的宣告

問題的原因就是xml約束檔案與jar包的版本號不一致,      解決方法:1. 聯網,網路聯通,工具會自己從網上查詢相應的jar的解析文件。  2.  斷網的情況了下,在applicationContext.xml中修改即可; 看一下Spring Jar包後面的版本號,比

Spring的配置檔案到元素 'beans' 的宣告

xml配置:<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="customerD" class="cn.edu.uestc.dao.CustomerDaoImpl"/>

cvc-elt.1: 到元素 'beans' 的宣告。springmvc netbeans maven

搭建最基本的框架,出現問題,提示cvc-elt.1: 找不到元素 'beans' 的宣告。 HTTP Status 500 - Servlet.init() for servlet spring threw exception type Exception report message&n

No Spring WebApplicationInitializer types detected on classpath 載入到配置檔案或spring主配置

第一種情況 在web.xml當中配置錯誤,沒有正確的引入spring的配置檔案。找不到時,報告次錯誤。 檢查配置檔案,引入是否正確。 classpath:springconfig.xml ,這個格式的配置為讀取本專案classpath下的檔案 classpath*:s