Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFa
2012-08-12 21:08
627 查看
添加上如下的一句就可以了
然后Spring的配置改为
其实对于使用
default-autowire="byName" default-lazy-init="true"
然后Spring的配置改为
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"default-autowire="byName" default-lazy-init="true">
其实对于使用
default-autowire="byName" default-lazy-init="true"
也还是要看情况来定的,搜了一下网上的,也有如下的问题
Spring default-autowire="byName"自动配置bean注入,(删掉了显示配置属性,还是可以注入,没发现这个属性的时候还以为是缓存的问题)。发现在spring中的Beans属性项中,写了这么一段“default-autowire="byName",. 恍然大悟,配置了这个属性项后,spring会对bean的属性自动按name去寻找,如果找到则set进去,而不必对Bean的属性进行显式的Set。仔细想想default-autowire="byName"应该算是最差实践吧,虽然能减少配置文件的书写量,可配置文件的可读性却大打折扣,一 个Bean你无法知道他有那些属性项,无法知道那些Bean与其相关,如果你碰巧修改了一个相关Bean而导致改Bean异常,估计要够你找的。配置文件和代码一样,应该可读性强,清晰明了,一看就能明白,而default-autowire="byName"会导致配置文件几乎无法可读,你无法明白这些bean之间的相互关系,如果是你自己维护还好,换个第三者来,估计要把写配置文件的骂个底朝天。 |
相关文章推荐
- MyBatis与Spring MVC结合时,使用DAO注入出现:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
- Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlMapClient' is required的解决办法及详细介绍
- Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a mana
- Invocation of init method failed; nested exception is java.lang.IllegalStateException:
- Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/
- Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
- Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
- Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:问题解决
- Invocation of init method failed; nested exception is java.lang.NoSuchMethodError
- Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:问题解决
- CXF2.7.0 Error creating bean with name '***': Invocation of init method failed; nested exception is
- Invocation of init method failed; nested exception is java.lang.NoSuchMethod
- Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class cn.e3mall.pojo.TbItem
- Bean 'shiroFilter'; nested exception is java.lang.IllegalArgumentException: Bean name must not be em
- Invocation of init method failed; nested exception is org.hibernate.PropertyAccessException: Illegal
- Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path reso
- IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"
- CXF2.7.0配置REST和spring时报错:Error creating bean with name '***': Invocation of init method failed; nested exception is ***.ServiceConstructionException
- 异常:Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentExceptio
- java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character position