您的位置:首页 > 其它

欢迎使用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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: