mysql的bean配置_spring中配置bean属性如何从外部配置文件中取值?

这篇博客详细介绍了如何在 Spring 配置文件中设置 MySQL 数据源以及 Hibernate 相关属性。内容包括数据源类型、驱动类、URL、用户名和密码等基本配置,以及连接池参数如 c3p0 的各项属性设置。同时,还展示了 Hibernate 的方言、批处理大小、查询显示等关键配置。此外,提到了 Spring 中引用这些配置的方式。
摘要由CSDN通过智能技术生成

datasource.type=mysql

datasource.driverClassName=org.gjt.mm.mysql.Driver

datasource.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8

datasource.username=root

datasource.password=123456

datasource.maxActive=10

datasource.maxIdle=2

datasource.maxWait=120000

datasource.whenExhaustedAction=1

datasource.validationQuery=select 1 from dual

datasource.testOnBorrow=true

datasource.testOnReturn=false

c3p0.acquireIncrement=3

c3p0.initialPoolSize=3

c3p0.idleConnectionTestPeriod=900

c3p0.minPoolSize=2

c3p0.maxPoolSize=50

c3p0.maxStatements=100

c3p0.numHelperThreads=10

c3p0.maxIdleTime=600

hibernate.dialect=org.hibernate.dialect.MySQLDialect

hibernate.jdbc.batch_size=25

hibernate.jdbc.fetch_size=50

hibernate.show_sql=true

hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory

hibernate.cglib.use_reflection_optimizer=true

hibernate.connection.release_mode=after_transaction

usercache.config=oscache.properties

blogcache.config=blogoscache.properties

在spring配置文件中引用方式为:

例如:

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

name="dataSource">

local="dataSource" />

name="hibernateProperties">

key="hibernate.cglib.use_reflection_optimizer">${hibernate.cglib.use_reflection_optimizer}

key="hibernate.query.factory_class">${hibernate.query.factory_class}

key="hibernate.dialect">${hibernate.dialect}

key="hibernate.show_sql">${hibernate.show_sql}

key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}

key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}

name="mappingDirectoryLocations">

classpath:/com/hbm/pojo 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值