解决方案 »

  1.   

    application的配置如下
    <?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:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 启用注解风格的配置 -->
    <context:annotation-config />
    <!-- 配置需要扫描的根包 -->
    <context:component-scan base-package="com.jtl.zhcs"/> <!-- 1.dataSource -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
    <property name="username" value="abc"/>
    <property name="password" value="abc"/>
    </bean>

    <!-- 2.sessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <!-- 2.1 dataSource -->
    <property name="dataSource" ref="dataSource"/>
    <!-- 2.2  方言等属性 -->
    <property name="hibernateProperties">
    <props>
          <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
          <prop key="hibernate.show_sql">true</prop>
          </props>
    </property>
    <!-- 2.3 需要扫描的实体类所在包 -->
    <property name="packagesToScan" value="com.jtl.zhcs.entity"/>
    </bean>
    <bean id="tm" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="tm"/></beans>
      

  2.   

    Spring 3.x 只支持Java7,要在Java8下跑,必须升级到Spring 4
      

  3.   


    大概知道了我去试试看配jar包