
spring
_海豚湾_
这个作者很懒,什么都没留下…
展开
-
java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist
初学Spring在用Resource rs=new ClassPathResource("applicationContext.xml");时老是遇到这个错误。后来发现用ApplicationContext ctx=new FileSystemXmlApplicationContext("WebContent/WEB-INF/applicationContext.xml");可以解决这个问题转载 2017-06-12 10:00:51 · 1251 阅读 · 0 评论 -
BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Applic
在网上查找很久,很多人说是因为错误写法:ApplicationContext ctx = new ClassPathXmlApplicationContext();时,没有指定配置文件,spring实例化BeanFactory的时候是默认到classPath下面查找名为applicationContext.xml的文件的,但是呢,你又没有指定,所以出现了这个错误。这就是错误转载 2017-06-13 14:48:10 · 501 阅读 · 0 评论 -
@Autowired与@Resource的区别
1、@Autowired与@Resource都可以用来装配bean. 都可以写在字段上,或写在setter方法上。两者如果都写在字段上,那么就不需要再写setter方法。2、@Autowired默认按类型装配(这个注解是属业spring的,需要导入包org.springframework.beans.factory.annotation.Autowired;),默认情况下必须要求依赖对象必须存转载 2017-07-21 11:26:46 · 335 阅读 · 0 评论 -
系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常
spring加载配置文件spring-dao.xml出错,抛出Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 77; cvc-elt.1: 找不到元素 'beans' 的声明。造成该异常原因有两种:第一,配置文件头部配置的xsd版本信息不正确,造成解析时出错。spring头部xsd转载 2017-07-18 14:45:26 · 4651 阅读 · 1 评论