#SSH配置文件整合笔记实例

spring-BaseBean.xml

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<!-- 读取db.propertieds配置文件 -->
<context:property-placeholder location="classpath:db.properties" />
<!-- 配置连接池c3p0 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${driverClass}" />
<property name="jdbcUrl" value="${jdbcUrl}" />
<property name="user" value="${user}" />
<property name="password" value="${password}" />
<!--当连接池中的连接用完时,C3P0一次性创建新连接的数目 -->
<property name="acquireIncrement" value="${acquireIncrement}" />
<!--初始化时创建的连接数,应在minPoolSize与maxPoolSize之间取值 -->
<property name="initialPoolSize" value="${initialPoolSize}" />
<!--minPoolSize连接池 最少连接数 -->
<property name="minPoolSize" value="${minPoolSize}" />
<!--maxPoolSize连接池 最大连接数 -->
<property name="maxPoolSize" value="${maxPoolSize}" />
<!--maxIdleTime最大空闲时间 -->
<property name="maxIdleTime" value="${maxIdleTime}" />
</bean> <!-- 配置sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<!-- 配置hibernate文件 -->
<list>
<value>com/pet/bean/xml/PetDiary.hbm.xml</value>
<value>com/pet/bean/xml/PetInfo.hbm.xml</value>
</list>
</property>
<!-- 配置hibernate系统执行读取配置文件 -->
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
hibernate.format_sql=true
</value>
</property>
</bean> <!-- 开启事物管理 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.pet.dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="select*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置bean对象 -->
<bean id="PetDiaryDaoImpl" class="com.pet.dao.impl.PetDiaryDaoImpl"> <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="PetInfoDaoImpl" class="com.pet.dao.impl.PetInfoDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="PetDiaryServiceImpl" class="com.pet.service.impl.PetDiaryServiceImpl">
<property name="petDiaryDaoImpl" ref="PetDiaryDaoImpl" />
</bean>
<bean id="PetInfoServiceImpl" class="com.pet.service.impl.PetInfoServiceImpl">
<property name="petInfoDaoImpl" ref="PetInfoDaoImpl" />
</bean>
</beans>

db.properties

driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://127.0.0.1:3306/javaee
user=root
password=765800
acquireIncrement=10
initialPoolSize=10
minPoolSize=3
maxPoolSize=500
maxIdleTime=1800

spring-ActionBean.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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-3.2.xsd"> <bean id="PetInfoAction" class="com.pet.struts.PetInfoAction">
<property name="petInfoServiceImpl" ref="PetInfoServiceImpl"/>
</bean>
</beans>

struts.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd"> <struts>
<!-- 开启开发者模式 -->
<constant name="struts.devMode" value="true" />
<!--把struts生产action的权利交给spring -->
<constant name="struts.objectFactory" value="spring" /> <package name="student" extends="json-default" namespace="/">
<action name="pet_*" class="PetInfoAction"
method="{1}">
<result type="json"/>
<allowed-methods>
selectAllPets,delete,selectById,insert
</allowed-methods>
</action>
</package>
</struts>

ps:配置文件仅供参考

JavaEE笔记(十四)的更多相关文章

  1. python3.4学习笔记(十四) 网络爬虫实例代码,抓取新浪爱彩双色球开奖数据实例

    python3.4学习笔记(十四) 网络爬虫实例代码,抓取新浪爱彩双色球开奖数据实例 新浪爱彩双色球开奖数据URL:http://zst.aicai.com/ssq/openInfo/ 最终输出结果格 ...

  2. 《C++游戏开发》笔记十四 平滑过渡的战争迷雾(二) 实现:真正的迷雾来了

    本系列文章由七十一雾央编写,转载请注明出处.  http://blog.csdn.net/u011371356/article/details/9712321 作者:七十一雾央 新浪微博:http:/ ...

  3. (C/C++学习笔记) 十四. 动态分配

    十四. 动态分配 ● C语言实现动态数组 C语言实现动态数组,克服静态数组大小固定的缺陷 C语言中,数组长度必须在创建数组时指定,并且只能是一个常数,不能是变量.一旦定义了一个数组,系统将为它分配一个 ...

  4. TCP/IP详解 笔记十四

    TCP/IP协议(二)  连接的建立与终止 tcpdump -S输出TCP报文的格式 格式: 源>目的:标志 (标志就是tcp头部).标识首字符意义如下: 例如:telnet 某服务的输出(包括 ...

  5. SharpGL学习笔记(十四) 材质:十二个材质球

    材质颜色 OpenGL用材料对光的红.绿.蓝三原色的反射率来近似定义材料的颜色.象光源一样,材料颜色也分成环境.漫反射和镜面反射成分,它们决定了材料对环境光.漫反射光和镜面反射光的反射程度.在进行光照 ...

  6. 【转】angular学习笔记(十四)-$watch(1)

    本篇主要介绍$watch的基本概念: $watch是所有控制器的$scope中内置的方法: $scope.$watch(watchObj,watchCallback,ifDeep) watchObj: ...

  7. How tomcat works 读书笔记十四 服务器组件和服务组件

    之前的项目还是有些问题的,例如 1 只能有一个连接器,只能处理http请求,无法添加另外一个连接器用来处理https. 2 对容器的关闭只能是粗暴的关闭Bootstrap. 服务器组件 org.apa ...

  8. SpringBoot笔记十四:消息队列

    目录 什么是消息队列 消息队列的作用 异步通信 应用解耦 流量削峰 RabbitMQ RabbitMQ流程简介 RabbitMQ的三种模式 安装RabbitMQ RabbitMQ交换器路由和队列的创建 ...

  9. 《Inside C#》笔记(十四) 反射

    通过反射可以在运行时动态地获取一个应用的元数据. 一 反射相关的类和方法 与反射相关的类处在System.Reflection命名空间下,包括Assembly.Module.MethodInfo.Fi ...

  10. angular学习笔记(十四)-$watch(1)

    本篇主要介绍$watch的基本概念: $watch是所有控制器的$scope中内置的方法: $scope.$watch(watchObj,watchCallback,ifDeep) watchObj: ...

随机推荐

  1. ONLYOFFICE连接数20个限制的由来

    搜onlyoffice document server的github上的issue,会得到这2个地址https://github.com/ONLYOFFICE/DocumentServer/issue ...

  2. Android比较实用的性能优化

    Android设备作为一种移动设备,无论是内存还是CPU的性能都受到了很大的限制,这导致Android程序的性能问题异常突出,随着产品的不断更新迭代,对于性能优化提出了更高的要求.本篇文章从稳定性.流 ...

  3. Python+Selenium笔记(十六)屏幕截图

    (一) 方法 方法 简单说明 save_screenshot(filename)   获取当前屏幕截图并保存为指定文件 filename:路径/文件名 get_screenshot_as_base64 ...

  4. SQL Server 2000中的并行处理和执行计划中的位图运算符

    SQL Server 2000中的并行处理和执行计划中的位图运算符 摘抄自:SQLServer 2000并行处理和位图简介 刘志斌 并行查询介绍Degree of Parallelism(并行度) 一 ...

  5. jmeter如何保持JSESSIONID

    利用Jmeter做接口测试的时候,如何提取头部的JSESSIONID然后传递到下一个请求,继续完成当前用户的请求. 一.如果响应数据里面没有返回JSESSIONID,直接添加http cookies ...

  6. Dictionary CovertTo List

    示例代码 假设有如下一个Dictionary 要转换成List Dictionary<string, string> dicNumber = new Dictionary<strin ...

  7. svn: 无法连接主机“127.0.0.1”: 拒绝连接

    尝试搭建SVN服务器,前面的步骤都OK,服务已经启动, svnserve -d --listen-port 80 --listen-host 0.0.0.0 -r /data/nerrissa/svn ...

  8. 开发jQuery插件的基本步骤

    在进行开发jQuery插件前,首先要了解一些知识: 1.闭包 1.1.闭包的作用: · 避免全局依赖 · 避免第三方破坏 · 兼容jQuery操作符'$'和jQuery 1.2.闭包的形式 (func ...

  9. swift protocol的几种形式

    三个关注点:1.形式:2.实现方式:3.使用方式: 一.基本形式: 形式:内部无泛型类型: 实现:只需指定类型和实现相应的功能即可: 使用:可以用在其他类型出现的任何地方: protocol Resp ...

  10. 随手练——DFS小练

    1. 单词接龙 https://www.luogu.org/problemnew/show/P1019 题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头 ...