#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平台轻松部署

    请移步至此,更详细:http://blog.csdn.net/hotqin888/article/details/79337881 ONLYOFFICE是一个免费的.开源的企业办公套件,用于在线组织团 ...

  2. Vue入门(二)之数据绑定

    Vue官网: https://cn.vuejs.org/v2/guide/forms.html#基础用法 [入门系列] (一)  http://www.cnblogs.com/gdsblog/p/78 ...

  3. 学习vue.js的正确姿势(转载)

    最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...

  4. SQLSERVER中的LOB页面简单研究

    SQLSERVER中的LOB页面简单研究 这篇文章和我另一篇文章是相辅相成的,在看<SQLSERVER2012 列存储索引的简单研究和测试>这篇文章之前希望大家先看一下这篇文章o(∩_∩) ...

  5. python if 判断

    #!/usr/bin/env python# -*- conding:utf-8 -*- if 条件: 执行1 执行2else: 执行3 if else 后面需要加: python严格缩进,内容1和内 ...

  6. Angular JS (一)

    AngularJS是一个js框架,以js编写的库.跟knockoutJS类似. AngularJS扩展了html 通过ng-directives扩展了html:ng-app定义一个angularJS应 ...

  7. NodeJS自定义模块

    //1.创建测试模块js文件(我这里命名为test.js) //2.添加测试方法 function test(){ console.log('Test Success!'); } //3.公开该方法到 ...

  8. EntityFramework Code-First 简易教程(二)-------Code First约定

    Code First 约定 在前一篇中,我们已经知道了EF Code-First怎样从模型类(domain classes)中创建数据库表,下面,我们开始学习默认的Code-First约定. 什么是约 ...

  9. How to Be Assertive Asking for What You Want Firmly and Fairly

    What Is Assertiveness? It's not always easy to identify truly assertive behavior. This is because th ...

  10. 自己动手制作一个本地的yum仓库

    制作本地yum源有两种方式,第一种是使用光盘镜像,然后在本地进行安装.第二种是我们自己创建一个本地yum仓库,然后使用file的形式来向本地提供yum repo(也可以使用http的方式向外部提供,我 ...