'sessionFactory' or 'h…
2013-11-05 14:30
375 查看
这是我的springApplicationContext.xml文件:
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.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/mssql-jdbc.properties</value>
</property>
</bean>
<!-- 配置DBCP数据源 -->
<bean id="dbcp_dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property
name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property
name="defaultAutoCommit">
<value>${jdbc.defaultAutoCommit}</value>
</property>
</bean>
<!-- 配置BenCp数据源 -->
<bean
id="bonecp_dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
destroy-method="close">
<property name="driverClass">
<value>${jdbc.driverClassName}</value>
</property>
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dbcp_dataSource"
/>
<!--ORM映射文件:mappingResources-->
<!-- ORM目录 -->
<property
name="mappingDirectoryLocations">
<value>classpath:com/zakhas/ospm/model/hbm/</value>
</property>
<property
name="hibernateProperties">
<props>
<!-- 数据库方言 -->
<prop
key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
<!-- 控制台是否打印SQL -->
<prop
key="hibernate.show_sql">${jdbc.hibernate.show_sql}</prop>
<!-- 控制台是否格式化SQL语句显示样式 -->
<prop
key="hibernate.format_sql">${jdbc.hibernate.format_sql}</prop>
<!-- 启用服务器时,检查hbm文件是否与数据库对应,不对应则抛出异常
<prop
key="hibernate.hbm2ddl.auto">validate</prop>
-->
<!-- 是否使用二级缓存 -->
<prop
key="hibernate.cache.use_second_level_cache">true</prop>
<!-- 启用缓存机制 -->
<prop
key="hibernate.cache.use_query_cache">true</prop>
<!-- 指定缓存提供商 -->
<prop
key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider</prop>
<!-- QueryCacheFactory的实现类
-->
<prop
key="hibernate.cache.query_cache_factory">
org.hibernate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
<!-- 配置事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property
name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 事务拦截器bean需要依赖注入一个事务管理器
-->
<property name="transactionManager"
ref="transactionManager" />
<property
name="transactionAttributes">
<!--
下面定义事务传播属性-->
<props>
<prop
key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="insert*">PROPAGATION_REQUIRED</prop>
<prop
key="save*">PROPAGATION_REQUIRED</prop>
<prop
key="update*">PROPAGATION_REQUIRED</prop>
<prop
key="edit*">PROPAGATION_REQUIRED</prop>
<prop
key="del*">PROPAGATION_REQUIRED</prop>
<prop
key="remove*">PROPAGATION_REQUIRED</prop>
<!-- 其它情况 -->
<prop
key="do*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!--
定义BeanNameAutoProxyCreator-->
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- 指定对满足哪些bean
name的bean自动生成业务代理 -->
<property name="beanNames">
<!--
下面是所有需要自动创建事务代理的bean-->
<list>
<value>baseServiceBean</value>
<value>loginInfoServiceBean</value>
<value>privilegeServiceBean</value>。。。。。
</list>
</property>
<!--
下面定义BeanNameAutoProxyCreator所需的事务拦截器-->
<property
name="interceptorNames">
<list>
<!-- 此处可增加其他新的Interceptor -->
<value>transactionInterceptor</value>
</list>
</property>
</bean>
</beans>
我是在daoimpl继承了HibernateDaoSupport,调用getHibernateTemplate()方法。
现在在service接口这里我也继承了这个类,然后再serviceimpl调用getHibernateTemplate()方法,没注意到
springApplicationContext.xml的配置,加载tomcat时候,就报错了:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: 'sessionFactory' or
'hibernateTemplate' is required
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.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/mssql-jdbc.properties</value>
</property>
</bean>
<!-- 配置DBCP数据源 -->
<bean id="dbcp_dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property
name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property
name="defaultAutoCommit">
<value>${jdbc.defaultAutoCommit}</value>
</property>
</bean>
<!-- 配置BenCp数据源 -->
<bean
id="bonecp_dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
destroy-method="close">
<property name="driverClass">
<value>${jdbc.driverClassName}</value>
</property>
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dbcp_dataSource"
/>
<!--ORM映射文件:mappingResources-->
<!-- ORM目录 -->
<property
name="mappingDirectoryLocations">
<value>classpath:com/zakhas/ospm/model/hbm/</value>
</property>
<property
name="hibernateProperties">
<props>
<!-- 数据库方言 -->
<prop
key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
<!-- 控制台是否打印SQL -->
<prop
key="hibernate.show_sql">${jdbc.hibernate.show_sql}</prop>
<!-- 控制台是否格式化SQL语句显示样式 -->
<prop
key="hibernate.format_sql">${jdbc.hibernate.format_sql}</prop>
<!-- 启用服务器时,检查hbm文件是否与数据库对应,不对应则抛出异常
<prop
key="hibernate.hbm2ddl.auto">validate</prop>
-->
<!-- 是否使用二级缓存 -->
<prop
key="hibernate.cache.use_second_level_cache">true</prop>
<!-- 启用缓存机制 -->
<prop
key="hibernate.cache.use_query_cache">true</prop>
<!-- 指定缓存提供商 -->
<prop
key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider</prop>
<!-- QueryCacheFactory的实现类
-->
<prop
key="hibernate.cache.query_cache_factory">
org.hibernate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
<!-- 配置事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property
name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 事务拦截器bean需要依赖注入一个事务管理器
-->
<property name="transactionManager"
ref="transactionManager" />
<property
name="transactionAttributes">
<!--
下面定义事务传播属性-->
<props>
<prop
key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="query*">PROPAGATION_REQUIRED,readOnly</prop>
<prop
key="insert*">PROPAGATION_REQUIRED</prop>
<prop
key="save*">PROPAGATION_REQUIRED</prop>
<prop
key="update*">PROPAGATION_REQUIRED</prop>
<prop
key="edit*">PROPAGATION_REQUIRED</prop>
<prop
key="del*">PROPAGATION_REQUIRED</prop>
<prop
key="remove*">PROPAGATION_REQUIRED</prop>
<!-- 其它情况 -->
<prop
key="do*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!--
定义BeanNameAutoProxyCreator-->
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- 指定对满足哪些bean
name的bean自动生成业务代理 -->
<property name="beanNames">
<!--
下面是所有需要自动创建事务代理的bean-->
<list>
<value>baseServiceBean</value>
<value>loginInfoServiceBean</value>
<value>privilegeServiceBean</value>。。。。。
</list>
</property>
<!--
下面定义BeanNameAutoProxyCreator所需的事务拦截器-->
<property
name="interceptorNames">
<list>
<!-- 此处可增加其他新的Interceptor -->
<value>transactionInterceptor</value>
</list>
</property>
</bean>
</beans>
我是在daoimpl继承了HibernateDaoSupport,调用getHibernateTemplate()方法。
现在在service接口这里我也继承了这个类,然后再serviceimpl调用getHibernateTemplate()方法,没注意到
springApplicationContext.xml的配置,加载tomcat时候,就报错了:
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: 'sessionFactory' or
'hibernateTemplate' is required
相关文章推荐
- One or more scree…
- Commands Of Oradebug
- GDB7.2&nbsp;Remote&nbsp;&#039;g&amp;…
- ssh 连接取消yes or no
- Don&#039;t&nbsp;lose&nbsp;our&nbsp;faith!&nbsp;---Remembe…
- Lesson 21 Mad or not? 是不是疯了
- Could not find action or result
- mysql 连接出错 'm…
- undefined&nbsp;reference&nbsp;to&nbsp;&#039;pthread_…
- bwibit.com&nbsp;doesn&#039;t&nbsp;work&nbsp;now,&nbsp;he1…
- PHP的$_SERVER['HTTP_H…
- Error&nbsp;(10028):&nbsp;Can&#039;t&nbsp;resol…
- centos or rhel puppet 安装
- -'PLAN_TABLE' is old version
- XML Parsing Error: XML or text d…
- apache&nbsp;提示You&nbsp;don&#039;t&nbsp;have&nbsp;permis…
- 关于 adding a new disk or removi…
- 拓扑排序hdu 3342 Legal or Not
- error&nbsp;C2065:&nbsp;&#039;priority_queue&#039;&nbsp;:&nbsp;…
- q2&nbsp;编译出现&nbsp;Can&#039;t&nbsp;place&nbsp;multiple…