加载spring时applicationContext.xml文件出错

今天联系Spring+Hibernate基础,没办法,SSH配置一直一直在出问题,只能一点一点的调了~
首先在新建工程的时候就出现了问题,用MyEclipse加入Spring支持的时候就出现了错误提示,T_T~~~~我明明嘛都米开始干呢。。。。。

applicationContext.xml头出现了问题,MyEclipse提示如下错误:
Referenced file contains errors(http://www.springframework.org/schema/beans/spring-beans-2.0.xsd).For more information,right click on the message and select "Show Details"

这个问题经过上网搜索查询反复的改正,终于解决。
原因如下:
原头信息:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

配置bean
</beans>
问题原因:我也不是特别清楚,估计是链接外网时出现问题,链接外网文件无法得到。

修改方法:
将头文件改为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

配置bean

</beans>
问题解决。

解决了配置问题,进行了简单测试又出现了一个小问题,运行时
出现如下错误:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [../applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [../applicationContext.xml] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [../applicationContext.xml] cannot be opened because it does not exist
阅读错误代码很容易发现,
程序无法加载applicationContext.xml文件,
仔细检查
ClassPathXmlApplicationContext ctc=new ClassPathXmlApplicationContext("/applicationContext.xml");
对路径进行复查,修改路径,问题解决~lucky~~~

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值