3
回答
spring3.2 hibernate4.2整合遇到的问题,求救!!!!
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

2013-6-5 9:40:10 org.springframework.web.context.ContextLoader initWebApplicationContext
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [DB_cfg.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)

....

配置文件:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <!-- 引入配置文件 -->
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>

  <!--配置数据源 连接池-->
 <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
        <property name="driverClass" value="${jdbc.driverClassName}" />
  <property name="driverUrl" value="${jdbc.url}" />
  <property name="user" value="${jdbc.username}" />
  <property name="password" value="${jdbc.password}" />
  <property name="maximumConnectionCount" value="${proxool.maxConnCount}" />
  <property name="minimumConnectionCount" value="${proxool.minConnCount}" />
        <property name="statistics" value="${proxool.statistics}" />
  <property name="simultaneousBuildThrottle" value="${proxool.simultaneousBuildThrottle}" />
  <property name="trace" value="${proxool.trace}" />
  <property name="verbose" value="${proxool.verbose}" />
   </bean>

 <!-- 会话配置 -->
 <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  <property name="dataSource">
    <ref bean="dataSource"/>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
   </props>
  </property>
  
  <property name="mappingResources">
   <list> 
    <!--项目应用实体对象  -->
    <value>eCardTo/entitys/User.hbm.xml</value>
   </list>
  </property>
 </bean>
 
 <!-- 事务管理配置 -->
 <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory" />
 </bean>
 
 <!--
  业务类声明式事务管理配模板,需要使用事务管理业务服务对象,直接继承此Bean[即配置parent属性为此bean的id],方便统一配置
 -->
 <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
  <property name="transactionManager" ref="transactionManager" />
  <property name="transactionAttributes">
   <props>
    <!-- 指明进行事务管理业务方法名[*是通配符] -->
    <prop key="add*">PROPAGATION_REQUIRED</prop>
    <prop key="edit*">PROPAGATION_REQUIRED</prop>
    <prop key="del*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
   </props>
  </property>
 </bean>

 <!--  Dao模板,具体实现Dao继承此bean的配置,省去各个Dao的重复配置 -->
 <bean id="daoTemplate" abstract="true">
  <property name="sessionFactory" ref="sessionFactory" />
 </bean>
 
</beans>

<无标签>
举报
zyxcast
发帖于5年前 3回/495阅
顶部