JavaEE笔记(十四)
#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笔记(十四)的更多相关文章
- python3.4学习笔记(十四) 网络爬虫实例代码,抓取新浪爱彩双色球开奖数据实例
python3.4学习笔记(十四) 网络爬虫实例代码,抓取新浪爱彩双色球开奖数据实例 新浪爱彩双色球开奖数据URL:http://zst.aicai.com/ssq/openInfo/ 最终输出结果格 ...
- 《C++游戏开发》笔记十四 平滑过渡的战争迷雾(二) 实现:真正的迷雾来了
本系列文章由七十一雾央编写,转载请注明出处. http://blog.csdn.net/u011371356/article/details/9712321 作者:七十一雾央 新浪微博:http:/ ...
- (C/C++学习笔记) 十四. 动态分配
十四. 动态分配 ● C语言实现动态数组 C语言实现动态数组,克服静态数组大小固定的缺陷 C语言中,数组长度必须在创建数组时指定,并且只能是一个常数,不能是变量.一旦定义了一个数组,系统将为它分配一个 ...
- TCP/IP详解 笔记十四
TCP/IP协议(二) 连接的建立与终止 tcpdump -S输出TCP报文的格式 格式: 源>目的:标志 (标志就是tcp头部).标识首字符意义如下: 例如:telnet 某服务的输出(包括 ...
- SharpGL学习笔记(十四) 材质:十二个材质球
材质颜色 OpenGL用材料对光的红.绿.蓝三原色的反射率来近似定义材料的颜色.象光源一样,材料颜色也分成环境.漫反射和镜面反射成分,它们决定了材料对环境光.漫反射光和镜面反射光的反射程度.在进行光照 ...
- 【转】angular学习笔记(十四)-$watch(1)
本篇主要介绍$watch的基本概念: $watch是所有控制器的$scope中内置的方法: $scope.$watch(watchObj,watchCallback,ifDeep) watchObj: ...
- How tomcat works 读书笔记十四 服务器组件和服务组件
之前的项目还是有些问题的,例如 1 只能有一个连接器,只能处理http请求,无法添加另外一个连接器用来处理https. 2 对容器的关闭只能是粗暴的关闭Bootstrap. 服务器组件 org.apa ...
- SpringBoot笔记十四:消息队列
目录 什么是消息队列 消息队列的作用 异步通信 应用解耦 流量削峰 RabbitMQ RabbitMQ流程简介 RabbitMQ的三种模式 安装RabbitMQ RabbitMQ交换器路由和队列的创建 ...
- 《Inside C#》笔记(十四) 反射
通过反射可以在运行时动态地获取一个应用的元数据. 一 反射相关的类和方法 与反射相关的类处在System.Reflection命名空间下,包括Assembly.Module.MethodInfo.Fi ...
- angular学习笔记(十四)-$watch(1)
本篇主要介绍$watch的基本概念: $watch是所有控制器的$scope中内置的方法: $scope.$watch(watchObj,watchCallback,ifDeep) watchObj: ...
随机推荐
- Lodash学习笔记
有多年开发经验的工程师,往往都会有自己的一套工具库,称为utils.helpers等等,这套库一方面是自己的技术积累,另一方面也是对某项技术的扩展,领先于技术规范的制订和实现. Lodash就是这样的 ...
- go语言练习:类型转换
package main import "fmt" func main() { var a int var b uint var c float32 var d float64 a ...
- LeetCode题解之Split Linked List in Parts
1.题目描述 2.题目分析 主要是理解题意,将每个子链表应该分得的节点个数计算清楚.利用除数和余数的方法进行计算. 3.代码 vector<ListNode*> splitListToPa ...
- windows系统相关命令及问题排查实践
1. 如何查看哪个端口被哪个程序占用? Netstat –ano|findstr "80" ->找到监听80端口的pid tasklist|findstr “<PID号 ...
- Azure 门户中基于角色的访问控制入门
面向安全的公司应侧重于向员工提供他们所需的确切权限. 权限过多,可能会向攻击者公开帐户. 权限太少意味着员工无法有效地完成其工作. Azure 基于角色的访问控制 (RBAC) 可通过为 Azure ...
- Oracle EBS INV创建保留
CREATE or REPPLACE PROCEDURE CreateReservation AS -- Common Declarations l_api_version NUMBER := 1.0 ...
- Mysql binlog 无法删除(purge命令无法删除)
1.版本 1)操作系统 cat /etc/issueCentOS release 6.6 (Final)Kernel \r on an \m cat /proc/versionLinux versio ...
- NFS 系统的搭建
问题: 由于工作,需要,不断得进行挂在硬盘重装系统,NFS 系统给了我一个很好的解决方案.于是决定写一篇博客,防止以后再次使用的时候,能够很快得重新建立NFS 文件系统. 调研: NFS(Networ ...
- Linux内核参数基础优化
web 服务负载均衡器常规网站服务器优化的基本配置: net.ipv4.tcp_fin_timeout =2 net.ipv4.tcp_tw_reuse =1 net.ipv4.tcp_tw_recy ...
- 乘风破浪:LeetCode真题_031_Next Permutation
乘风破浪:LeetCode真题_031_Next Permutation 一.前言 这是一道经典的题目,我们实在想不出最好的方法,只能按照已有的方法来解决,同时我们也应该思考一下为什么要这样做?是怎么 ...