eclipse spring 报错
application.xml的位置也放对了,依赖也加了
代码也没有报错 测试的时候出错了
这是 info信息,不是报错,你看看还有没有其他错了?
在src目录下创建spring的配置文件applicationContext.xml,并在该文件中使用实现类TestDaoImpl,创建一个id为test的Bean。
代码如下:
<?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/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 将指定类TestDaoImpl配置给Spring,让Spring创建其实例 -->
<bean id="test" class="dao.TestDaoImpl"/>
</beans>
配置文件的名称可以自定义,但习惯上命名为applicationContext.xml,有时候也会命名为beans.xml。
配置文件不需要手写,可以在spring的帮助文件中复制(首先使用浏览器打开“\spring-framework-5.0.2.RELEASE\does\spring-framework-reference\index.html”,点击页面中超链接Core,在1.2.1 Configuration metadata 小节下即可找到配置文件的约束信息。)这个是书上写的我没打开,所以我又在官网找了。
首先,打开官网spring-framework的界面,点击Reference Doc. 进入下一个界面
其次,点击Core,进入下一个界面
最后,找到1.2.1章节,就可以找到对应的配置文件了。