搜尋

首頁  >  問答  >  主體

java - spring 练习遇到问题?

log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [autowire.xml]; nested exception is java.io.FileNotFoundException: class path resource [autowire.xml] cannot be opened because it does not exist

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<code>at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)

at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)

at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)

at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)

at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)

at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

at com.Spring.autowire.Main.main(Main.java:8)</code>

Caused by: java.io.FileNotFoundException: class path resource [autowire.xml] cannot be opened because it does not exist

1

2

3

4

<code>at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)

... 13 more

</code>


为什么xml文件存在,报错却说文件不存在啊

ringa_leeringa_lee2810 天前653

全部回覆(4)我來回復

  • 高洛峰

    高洛峰2017-04-18 10:51:57

    autowire.xml路径不对, 你要放到src下面, 和applicationContext.xml同目錄

    回覆
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:51:57

    找不到autowire.xml這個文件,如果你要放在包裡面,路徑要從src開始寫,classpath:src/com/Spring/autowire/autowire.xml,要不然就放在src目錄下用classpath: autowire.xml

    回覆
    0
  • 阿神

    阿神2017-04-18 10:51:57


    類路徑下找不到autowire.xml文件,也就是位置放錯了,和applicationContext.xml放一起就行

    回覆
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:51:57

    放在src裡面,所有包包的最外層。

    回覆
    0
  • 取消回覆