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: ...
随机推荐
- VS2010部署相关
找到一篇写得最负责的.贴住收藏了: http://blog.csdn.net/xhf55555/article/details/7702212. 之前在其它地方找的都缺胳膊少腿,真不知他们自己怎么实现 ...
- CentOS 7 环境下 GitLab安装部署以及账号初始化
1. 安装相关依赖 yum install curl policycoreutils openssh-server openssh-clients -y # 确保sshd启动(正常情况下, sshd是 ...
- 美团SQL优化工具SQLAdvisor
介绍 在数据库运维过程中,优化 SQL 是 DBA 团队的日常任务.例行 SQL 优化,不仅可以提升程序性能,还能够降低线上故障的概率. 目前常用的 SQL 优化方式包括但不限于:业务层优化.SQL逻 ...
- db2错误代码大全
---恢复内容开始--- sqlcode sqlstate 说明000 00000 SQL语句成功完成01xxx SQL语句成功完成,但是有警告+012 01545 未限定的列名被解释为一个有相互关系 ...
- THE ELEMENTS OF C# STYLE
|前言 程序员其实艺术家,灵动的双手如行云流水般在键盘上创造着生命的奇迹,我认为代码是有灵魂的.同一个模块,在每个程序员手中所缔造出来的是不相同的. 最终,这个模块或者实现了最初的业务,但是回过头看看 ...
- Difference between HashMap and Hashtable | HashMap Vs Hashtable
Both the HashMap and Hashtable implement the interface java.util.Map but there are some slight diffe ...
- dns服务器测试工具
下载地址:https://www.eatm.app/wp-content/uploads/2018/08/eDnsTest.20180810.zip
- olivettifaces数据集实现人脸识别代码
数据集: # -*- coding: utf-8 -*- """ Created on Wed Apr 24 18:21:21 2019 @author: 92958 & ...
- 第二次项目冲刺(Beta版本)
第二次项目冲刺(Beta版本) 团队作业7--第二次项目冲刺(Beta版本)day1 http://www.cnblogs.com/wj946/p/8017787.html 团队作业7--第二次项目冲 ...
- myeclipse10配置maven
一:Maven的下载安装 准备工作: 1)安装环境 Windows xp 2)需安装JDK ,并配置环境变量(略) 3) Maven版本3.0.5 4)下载地址:http://mirror.bit.e ...