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>
        
  • 相关阅读:
    django之admin管理工具
    django之中间件
    cookie和session
    day052-53 django框架
    day050 前端Jquery库的使用
    sprint
    Scrum 项目1.0
    【团队项目】3.0
    [读书笔记]
    【团队项目】2.0
  • 原文地址:https://www.cnblogs.com/lirenzhujiu/p/5861245.html
Copyright © 2011-2022 走看看