spring mvc mysql配置_SpringMVC配置文件及数据库连接池配置

本文介绍了如何配置Spring MVC与MySQL数据库连接,包括hibernate.properties文件中的 dataSource 设置,如数据库驱动、用户名、密码、方言和URL。同时,文章提到了因网络问题手动添加的c3p0-0.9.1.1.jar依赖,以及应用上下文XML文件(applicationContext.xml)的详细配置,包括SessionFactoryBean、事务管理器和相关命名空间的引用。
摘要由CSDN通过智能技术生成

hibernate.properties配置文件的简单配置信息:

dataSource.driverClassName= com.mysql.jdbc.Driver

dataSource.username = root

dataSource.password = root

dataSource.dialect = www.tongmap.cn.utils.MySQLDialectImpl

dataSource.url = jdbc:mysql://localhost:3306/sm

dataSource.hbm2ddl.auto = update

maven配置的jar依赖pom.xml,说明一下,native类型的jar包是我自己下载jar包后手工添加到本地仓库中的,并不是使用maven自动下载的(网络问题),使用maven下载需要把native修改为com.cloudhopper.proxool:

c3p0

c3p0

0.9.1.1

注意:我使用的c3p0版本为0.9.1.1,所以只要一个jar包就可以了,如果使用更新版本的c3p0,会有两个jar包,以c3p0-0.9.2.1为例,会需要以下依赖:

com.mchange

c3p0

0.9.2.1

com.mchange

mchange-commons-java

0.2.3.4

applicationContext.xml文件的配置,至于更详细的大家可以在官网中查看资料,每个配置的官网我在注释中有说明:

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"

xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-4.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-4.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

destroy-method="close">

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

${dataSource.dialect}

${dataSource.hbm2ddl.auto}

true

true

true

www.tongmap.cn.entity

class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />

class="org.springframework.orm.hibernate4.HibernateTransactionManager">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值