spring+hibernate+mysql mvc 配置

<? xmlversion="1.0"encoding="UTF-8" ?>
<! DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//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 >
有时间再对以上配置解释.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值