欢迎使用CSDN-markdown编辑器
2016-02-16 23:57
253 查看
这里写代码片<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- 建立数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/myssh"> </property> <property name="username" value="root"></property> <property name="password" value="1234"></property> </bean> <!-- 将数据源注入给Session工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <!-- 映射文件 --> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> </props> </property> </bean></beans>
<!-- 设置数据库连接池的最大连接数 --> <property name="maxPoolSize"> <value>20</value> </property> <!-- 设置数据库连接池的最小连接数 --> <property name="minPoolSize"> <value>2</value> </property> <!-- 设置数据库连接池的初始化连接数 --> <property name="initialPoolSize"> <value>2</value> </property> <!-- 设置数据库连接池的连接的最大空闲时间,单位为秒 --> <property name="maxIdleTime"> <value>20</value> </property> </bean>
<bean id="Bean实例名称" class="Bean类全名" scope="prototype" init-method="初始化调用的方面名" destroy-method="对象销毁时的方法名"> <!-- id指定Bean 类的 命名 class 指定 默认构造方法创实例 scope = prototype 指定原型模式,默认单例模式 init 指定对象实例化后的要调用的初始化方法 --> <property name="Bean类中属性名称" ref="要引用的Bean名称"></property> <property name="dfs" value="直接值"></property> <property name="sdf"> <bean class="匿名内部Bean赋值到指定的sdf中,外部无法访问"></bean> </property> <property name="Bean类中Set list map"> <set> <value>Set中元素</value> <refbean="value是Bean实例时用refbean"/> </set> <map> <entry key ="map的key"> <value>map key 对应的值</value> </entry> <entry key="key"> <ref="Bean名称"/> </entry> </map> </property> <property name="null对应的Bean属性名"> <null></null> </property> </bean> <bean id="" class=""> <constructor-arg index="从0开始序号" type="构造参数类型" value=""></constructor-arg> <constructor-arg index="从0开始序号" type="构造参数类型" ref=""></constructor-arg> </bean> ``
<!-- 配置事务管理器 --> <bean id="事务管理实例名称" class="全类名"></bean> <!-- 配置事务 --> <tx:advice id="事务通知名称" transaction-manager="事务通知实例名称"></tx:advice> <!-- AOP实现事务管理 --> <aop:config> <aop:aspect id="切面ID" ref="要引用实例名称"> <aop:pointcut expression="切入点的正则表示" id="切入点"/> <aop:before method="切面类中做前置通知的方法名" pointcut-ref=""/> <aop:after-returning method="后置通知" pointcut-ref=""/> <aop:after-throwing method="异常通知" pointcut-ref=""/> <aop:after method="最终通知" pointcut-ref=""/> <aop:around method="环绕通知" pointcut-ref=""/> </aop:aspect> </aop:config>
相关文章推荐
- 程序设计第三次作业---C++计算器雏形
- objective-C学习 NSUserDefaults 相当于缓存
- [20160216] 自带中断点的线程模型
- AVR121-使用过采样增加ADC精度
- ASP.NET 身份验证机制
- 个人作品- 几何战争
- Rational Rose Enterprise Edition安装使用
- resharper10.0.2注册机安装
- Android开发之Service
- 转: Rest简介及Spring实现
- HDOJ 1005 Number Sequence
- 原型链进阶
- UICollectionView添加Header Footer没被调用
- 关于字符串的几个常见问题
- 资源打包
- 全排列的递归实现(java代码)
- 使用CSDN-markdown编辑器
- VTK/Tutorials/New Pipeline文档翻译
- Equals和==的比较
- 【每周一文】Factorization Machines