您的位置:首页 > 编程语言 > Java开发

spring+hibernate+mysql mvc 配置

2007-09-12 10:22 381 查看

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


<beans>





<bean id="viewResolver"


class="org.springframework.web.servlet.view.InternalResourceViewResolver">


<property name="viewClass">


<value>


org.springframework.web.servlet.view.JstlView


</value>


</property>





<property name="prefix">


<value>


/admin/


</value>


</property>





<property name="suffix">


<value>.jsp</value>


</property>


</bean>





<bean id="urlMapping"


class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">


<property name="mappings">


<props>


<prop key="/admin/login.do">LoginAction</prop>


</props>


</property>


</bean>





<bean id="exceptionResolver"


class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">


<property name="defaultErrorView">


<value>failure</value>


</property>





<property name="exceptionMappings">


<props>


<prop key="java.sql.SQLException">showDBError</prop>


<prop key="java.lang.RuntimeException">showError</prop>


</props>


</property>


</bean>





<bean id="dataSource"


class="org.apache.commons.dbcp.BasicDataSource"


destroy-method="close">





<property name="driverClassName">


<value>org.git.mm.mysql.Driver</value>


</property>





<property name="url">


<value>jdbc:mysql://localhost:3306/babyonline</value>


</property>





<property name="username">


<value>root</value>


</property>





<property name="password">


<value>123456</value>


</property>


</bean>





<bean id="sessionFactory"


class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">





<property name="dataSource">


<ref local="dataSource"/>


</property>





<property name="mappingResources">


<list>


<value></value>


</list>


</property>





<property name="hibernateProperties">


<props>


<prop key="hibernate.dialect">


org.hibernate.dialect.MySQLDialect


</prop>


<prop key="hibernate.show_sql">


true


</prop>


</props>


</property>


</bean>





<bean id="transactionManager"


class="org.springframework.jdbc.datasource.DataSourceTransactionManager">


<property name="dataSource">


<ref local="dataSource"/>


</property>


</bean>





<bean id="userDAO" class="">


<property name="sessionFactory">


<ref local="sessionFactory"/>


</property>


</bean>





<bean id="userDAOProxy"


class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">


<property name="transactionManager">


<ref bean="transactionManager"/>


</property>





<property name="target">


<ref local="userDAO"/>


</property>





<property name="transactionAttributes">


<props>


<prop key="insert*">PROPAGATION_REQUIRED</prop>


<prop key="get*">PROPAGATION_REQUIRED,readonly</prop>


</props>


</property>


</bean>


</beans>

有时间再对以上配置解释.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: