Dorado 9 : 4.2.6 修改app-context.xml

修改standardlesson工程中WebContext/dorado-home目录中的app-context.xml,将数据库配置信息加入,修改后完整代码如下所示:

<?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:jee="http://www.springframework.org/schema/jee" 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-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <context:component-scan base-package="com.bstek.dorado"></context:component-scan>
    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driver}" />
        <property name="url" value="jdbc:mysql:${jdbc.url}?useUnicode=true&amp;characterEncoding=utf8"/>
        <property name="username" value="${jdbc.userName}" />
        <property name="password" value="${jdbc.password}" />
        <property name="minIdle" value="${jdbc.minIdle}" />
        <property name="maxActive" value="${jdbc.maxActive}" />
    </bean>
     
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="entityInterceptor" ref="dorado.unByteCodeProxyInterceptor" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.showSql}</prop>
                <prop key="hibernate.format_sql">${hibernate.formatSql}</prop>
            </props>
        </property>
        <property name="packagesToScan">
            <list>
                <value>com/bstek/dorado/sample/standardlesson/entity</value>
            </list>
        </property>
    </bean>
 
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
     
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>

对于配置信息的含义,请自行查阅相关资料,在此不进行逐一讲解。