zoukankan      html  css  js  c++  java
  • jdbc配置Spring

    hibernate.properties

    dataSource.password=123
    dataSource.username=root
    dataSource.databaseName=test
    dataSource.driverClassName=com.mysql.jdbc.Driver
    dataSource.dialect=org.hibernate.dialect.MySQL5Dialect
    dataSource.serverName=localhost:3306
    dataSource.url=jdbc:mysql://localhost:3306/test
    dataSource.properties=user=${dataSource.username};databaseName=${dataSource.databaseName};serverName=${dataSource.serverName};password=${dataSource.password}
    dataSource.hbm2ddl.auto=update

    applicationContext.xml

    <bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">${dataSource.dialect}</prop>
                    <prop key="hibernate.hbm2ddl.auto">${dataSource.hbm2ddl.auto}</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                </props>
            </property>
            <property name="packagesToScan">
                <list>
                    <value>com.mvc.entity</value><!-- 扫描实体类,也就是平时所说的model -->
                </list>
           </property>
        </bean>
    
        <bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory" />
            <property name="dataSource" ref="dataSource" />
        </bean>
    
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="${dataSource.driverClassName}" />
            <property name="url" value="${dataSource.url}" />
            <property name="username" value="${dataSource.username}" />
            <property name="password" value="${dataSource.password}" />
        </bean>
        
  • 相关阅读:
    jqueryUI弹出框问题
    spring data jpa分页
    解决eclipse编辑js和html卡的问题
    web.xml添加编码过滤器
    Apache SolrCloud安装
    搭建zookeeper集群
    html页面读取PDF小案例
    .NET 使用Process调用7_zip解压文件
    .NET 中三种正确的单例写法
    Git 笔记
  • 原文地址:https://www.cnblogs.com/lirenzhujiu/p/5861245.html
Copyright © 2011-2022 走看看