zoukankan      html  css  js  c++  java
  • 关于SSH的框架的整合

    <?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:aop="http://www.springframework.org/schema/aop"
            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/aop
                        http://www.springframework.org/schema/aop/spring-aop.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context.xsd">
                      
       <!-- 数据源:c3p0-->
       <bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
           <property name="driverClass"  value="${jdbc.driverClass}"></property>
           <property name="jdbcUrl"  value="${jdbc.url}"></property>
           <property name="user"  value="${jdbc.username}"></property>
           <property name="password"  value="${jdbc.password}"></property>
       </bean>
       <!-- 注册jdbc.properties文件 -->
       <context:property-placeholder location="classpath:jdbc.properties"/>
       
       <!-- 注册sessionFactory -->
       <bean  id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
               <property name="dataSource" ref="myDataSource"/>
               <property name="packagesToScan" value="com.layne.beans"/>
               <property name="hibernateProperties">
                  <props>
                         <!-- 当前session上下文 -->
                         <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
                         <!-- 方言 -->
                         <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                         <!-- 自动建表 -->
                         <prop key="hibernate.hbm2ddl.auto">update</prop>
                         <!--显示SQL语句  -->
                         <prop key="hibernate.show_sql">true</prop>
                         <!-- SQL语句格式化 -->
                         <prop key="hibernate.format_sql">true</prop>
                      </props>
               </property>
       </bean>
       
      <!-- 扫描 --> 
      <context:component-scan base-package="com.layne"/>
      
       <!-- 注册事物管理器 -->
       <bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
             <property name="sessionFactory" ref="sessionFactory"></property>
       </bean>  
       <!-- 使用注解配置事物:事物驱动注册 -->
       <tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
                        
    </beans>

    数据库访问资源文件:

    jdbc.driverClass=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/test
    jdbc.username=root
    jdbc.password=

    项目结构树:

    jar包地址:http://download.csdn.net/download/lg_xulei/10028827

    该项目使用EasyUI插件。

    资源下载地址:http://download.csdn.net/download/lg_xulei/10131521

  • 相关阅读:
    python脚本 快速执行mapreduce程序
    ArrayList中contains()的使用方法
    利用jstl标签实现国际化
    device eth0 does not seem to be present, delaying initialization
    java中compareTo和compare方法之比较
    CentOS 7 NAT模式LVS搭建
    CentOS 7 DR模式LVS搭建
    CentOS 7 开机延迟解决办法
    CentOS 7 nginx+tomcat9 session处理方案之session复制
    Jumpserver(跳板机、堡垒机)启动jms Django连接mysql数据库报错
  • 原文地址:https://www.cnblogs.com/flytogalaxy/p/7890987.html
Copyright © 2011-2022 走看看