1. 程式人生 > >ApplicationContext讀取xml配置檔案 報錯

ApplicationContext讀取xml配置檔案 報錯

配置檔案:

public class App {
    public static void main( String[] args )
    {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("/applicationContext-aop.xml");
        StudentService personService = appContext.getBean(StudentService.class);
        String personName = "AOP測試";
        personService.addPerson(personName);
        personService.deletePerson(personName);
        personService.editPerson(personName);
        ((ClassPathXmlApplicationContext)appContext).close();
    }
}
執行時報錯

錯誤:

16:36:29.742 [main] INFO  o.s.c.s.ClassPathXmlApplicationContext - Refreshing org[email protected]8ba2fae: startup date [Mon Nov 20 16:36:29 CST 2017]; root of context hierarchy

[v3]16:36:29.859 [main] INFO  o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [class:applicationContext-aop.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [class:applicationContext-aop.xml]; nested exception is java.io.FileNotFoundException: class path resource [class:applicationContext-aop.xml] cannot be opened because it does not exist

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:539)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at net.newcapec.aop.App.main(App.java:12)
Caused by: java.io.FileNotFoundException: class path resource [class:applicationContext-aop.xml] cannot be opened because it does not exist

at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:171)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)

... 13 more

怎麼解決?

相關推薦

ApplicationContext讀取xml配置檔案

配置檔案: public class App { public static void main( String[] args ) { ApplicationContext appContext = new ClassPathXmlAppl

c3p0連線池xml配置檔案的處理

有下劃線並提示 The word is not correctly spelled, 此問題是Eclipse校驗單詞拼寫造成的。 解決辦法如下:   Window--Preference輸入spell,然後把第一個複選框“Enable spell checking“去掉對勾就

關於dubbo服務的xml配置檔案的問題——The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'

  在配置dubbo服務的過程中,經常會遇到雖然程式能夠跑起來,但是配置檔案一堆紅叉,雖然不影響功能,但是確實很讓人噁心。   報錯資訊如下:     解決方案:   下載一個dubbo.xsd檔案(就在dubbo.jar裡面)windows->preferrence->xm

【dubbo之.xml配置檔案】Multiple annotations found at this line: - cvc-complex-type.2.4.c: The

【dubbo之.xml配置檔案報錯】Multiple annotations found at this line: - cvc-complex-type.2.4.c: The 下載地址:https://pan.baidu.com/s/16N0PDU0zcyFWlMa2PML1OA 做法:https

關於dubbo服務的xml配置檔案的問題

在配置dubbo服務的過程中,經常會遇到雖然程式能夠跑起來,但是配置檔案一堆紅叉,雖然不影響功能,但是確實很讓人噁心。 報錯資訊如下: Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildca

maven 工程 dubbo服務的xml配置檔案的問題

dubbo配置檔案報錯 在配置dubbo服務的過程中,經常會遇到雖然程式能夠跑起來,但是配置檔案一堆紅叉,雖然不影響功能,但是確實很讓人噁心。 報錯資訊如下: Multiple annotations found at this line: – cvc-comp

Eclipse中xml配置檔案原因總結

1)使用Eclipse開發工具,從SVN或者GIt上down下來的專案有的XML檔案報錯(提交上去的程式碼都是沒有問題的),而在本地Eclipse中卻顯示有問題,一般原因是Eclipse中對專案工程的校驗,點工程右鍵>Properties>Validation

xml約束檔案找不到xx.xsd的時候,清理下快取 問題解決

Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.0.xsd). For more information, right click on the  mes

Eclipse-Eclispe匯入正確工程後出現xml檔案

第一步:Project Explorer (如果沒有這個視窗可以在eclipse工具欄->Window->show View ->Project Explorer)->選中一個倒三角標誌->Customize view(如圖1) ->Conten

Java讀取XML配置檔案

1.定義webConfiguration.xml檔案(名字隨取) 2.定義對應配置檔案實體類 import java.io.Serializable;//實現序列化介面是為方便轉成檔案,對應JSON public class WebConfiguratinEntity implements

dubbo配置檔案schema_reference.4: Failed to read schema document ...

Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for e

applicationContext-mybatis.xml 配置檔案

applicationContext-mybatis.xml 配置檔案 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.

模擬瀏覽器路徑 通過讀取XML配置檔案的方式來使用反射完成對例項物件方法呼叫

反射: JAVA反射機制是在執行狀態中,對於任意一個實體類,都能夠知道這個類的所有屬性和方法;對於任意一個物件,都能夠呼叫它的任意方法和屬性;這種動態獲取資訊以及動態呼叫物件方法的功能稱為java語言的反射機制。    API: XML例子:

C#讀取xml配置檔案

  一、配置xml   <?xml version="1.0" encoding="utf-8" ?> <configuration> <Section Name="system">

初學springmvc applicationContext-springmvc.xml配置檔案

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XM

python讀取已存在檔案windowserror:[error 3]

怨念太深。。開始讀取檔案程式碼為: import pandas as pd Input=pd.read_csv(excelPath, index_col=0,encoding='utf-8',low_memory=False) 報錯: IOError: File C:\

讀取.XML配置檔案

///<summary> ///讀取配置檔案資訊,配置檔案伺服器程式當前路徑下GisServiceConfig.xml ///</sumary> ///<param name="p_key">XML節點名稱</param> /

java讀取xml配置檔案(小結)

使用DOM解析XML文件時,需要讀入整個XML文件,然後在記憶體中建立DOM樹,生成DOM樹上的每個節點物件。只有在整個DOM樹建立完畢後,我們才能做其他的操作,即使我們只需要修改根元素節點的第二個子節點,仍然需要在進行這個小小的修改之間分析整個文件,在記憶體中構建文件樹。當

C# 單例模式讀取xml配置檔案屬性值

 單例模式讀取xml配置檔案屬性值要求:       程式啟動後, 配置檔案中的屬性值要保持不變,才能起到作用;如果屬性值在程式執行中一直在變化,那麼就沒有必要使用單例模式。 class SingleXMLConfigInfo { #reg

配置檔案:不允許有匹配 "[xX][mM][lL]" 的處理指令目標

   當我執行專案時,發現專案報錯了,但是我對照了好幾遍都對的,隨後百度了下錯誤,發現原來是web.xml 那有錯了。 原來我在<?xml version="1.0" encoding="U