Spring+Dubbo+MyBatis+Linner分布式Web开发环境(一)

     本文承接《Spring+Maven+Dubbo+MyBatis+Linner+Handlebars—Web开发环境搭建》,以下对相关的Maven配置和详细的Spring配置文件进行简单介绍。

       整个开发框架大体结构如下:

        

      1) 核心业务逻辑工程用于处理系统自身的核心业务逻辑;

      2) 桥梁工程用于关联页面工程和后台处理逻辑;

      3) 公共业务逻辑对公共的业务逻辑进行处理;

      4) Maven父工程用于对整个开发环境进行配置,包括jar包的定义与管理,系统基本环境的配置(例:数据库连接的管理);

      5) 客户端接口工程用于发布服务给桥梁工程或可信任的第三方调用;

      6) 客户端接口实现工程用于具体实现服务接口;

      7) 任务调度工程用于处理相关任务调度;

      8) 总的框架工程用于对前面的后台工程进行统一的管理。

    以下我将对各个工程进行逐一介绍:

1.核心业务逻辑mkhl-biz:

     mkhl-biz工程的具体结构如下图:
    

   1)biz工程的pom文件:

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0"?>  
  2. <project  
  3.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"  
  4.     xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
  5.     <modelVersion>4.0.0</modelVersion>  
  6.     <parent>  
  7.         <artifactId>mkhl-parent</artifactId>  
  8.         <groupId>com.ouc.mkhl.supplier</groupId>  
  9.         <version>1.0</version>  
  10.         <relativePath>../mkhl-parent/pom.xml</relativePath>  
  11.     </parent>  
  12.     <artifactId>mkhl-biz</artifactId>  
  13.     <name>mkhl-biz</name>  
  14.     <url>http://maven.apache.org</url>  
  15.     <properties>  
  16.         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  17.     </properties>  
  18.     <dependencies>  
  19.         <!-- oop开放平台核心业务(此jar包须具有相关开发权限) -->  
  20.         <dependency>  
  21.             <groupId>com.ouc</groupId>  
  22.             <artifactId>oop-core</artifactId>  
  23.         </dependency>  
  24.         <dependency>  
  25.             <groupId>weblogic</groupId>  
  26.             <artifactId>wlfullclient</artifactId>  
  27.             <scope>provided</scope>  
  28.         </dependency>  
  29.         <dependency>  
  30.             <groupId>com.alibaba</groupId>  
  31.             <artifactId>dubbo</artifactId>  
  32.         </dependency>  
  33.           
  34.         <!--   
  35.         <dependency>   
  36.             <groupId>redis.clients</groupId>   
  37.             <artifactId>jedis</artifactId>   
  38.         </dependency>   
  39.         -->  
  40.           
  41.         <dependency>  
  42.             <groupId>com.ouc.mkhl.supplier</groupId>  
  43.             <artifactId>mkhl-service-client</artifactId>  
  44.             <exclusions>  
  45.                 <exclusion>  
  46.                     <groupId>ch.qos.logback</groupId>  
  47.                     <artifactId>logback-classic</artifactId>  
  48.                 </exclusion>  
  49.             </exclusions>  
  50.         </dependency>  
  51.         <dependency>  
  52.             <groupId>com.ouc.mkhl.supplier</groupId>  
  53.             <artifactId>mkhl-common</artifactId>  
  54.         </dependency>  
  55.         <dependency>  
  56.             <groupId>org.mybatis</groupId>  
  57.             <artifactId>mybatis-spring</artifactId>  
  58.         </dependency>  
  59.         <dependency>  
  60.             <groupId>org.mybatis</groupId>  
  61.             <artifactId>mybatis</artifactId>  
  62.         </dependency>  
  63.         <dependency>  
  64.             <groupId>org.mybatis.generator</groupId>  
  65.             <artifactId>mybatis-generator-core</artifactId>  
  66.         </dependency>  
  67.         <dependency>  
  68.             <groupId>com.github.sgroschupf</groupId>  
  69.             <artifactId>zkclient</artifactId>  
  70.         </dependency>  
  71.         <dependency>  
  72.             <groupId>org.apache.zookeeper</groupId>  
  73.             <artifactId>zookeeper</artifactId>  
  74.         </dependency>  
  75.   
  76.         <dependency>  
  77.             <groupId>javax.jms</groupId>  
  78.             <artifactId>jms-api</artifactId>  
  79.         </dependency>  
  80.         <dependency>  
  81.             <groupId>org.springframework</groupId>  
  82.             <artifactId>spring-jms</artifactId>  
  83.         </dependency>  
  84.         <dependency>  
  85.             <groupId>com.oracle</groupId>  
  86.             <artifactId>ojdbc14</artifactId>  
  87.         </dependency>  
  88.   
  89.         <!-- mysql连接 -->  
  90.         <dependency>  
  91.             <groupId>mysql</groupId>  
  92.             <artifactId>mysql-connector-java</artifactId>  
  93.             <!-- <version>5.1.34</version> -->  
  94.         </dependency>  
  95.         <dependency>  
  96.             <groupId>commons-pool</groupId>  
  97.             <artifactId>commons-pool</artifactId>  
  98.             <!-- <version>1.6</version> -->  
  99.         </dependency>  
  100.         <dependency>  
  101.             <groupId>commons-dbcp</groupId>  
  102.             <artifactId>commons-dbcp</artifactId>  
  103.             <!-- <version>1.4</version> -->  
  104.         </dependency>  
  105.   
  106.         <dependency>  
  107.             <groupId>org.aspectj</groupId>  
  108.             <artifactId>aspectjweaver</artifactId>  
  109.         </dependency>  
  110.         <dependency>  
  111.             <groupId>cglib</groupId>  
  112.             <artifactId>cglib</artifactId>  
  113.         </dependency>  
  114.         <dependency>  
  115.             <groupId>aopalliance</groupId>  
  116.             <artifactId>aopalliance</artifactId>  
  117.         </dependency>  
  118.         <!-- XStream -->  
  119.         <dependency>  
  120.             <groupId>com.thoughtworks.xstream</groupId>  
  121.             <artifactId>xstream</artifactId>  
  122.         </dependency>  
  123.         <dependency>  
  124.             <groupId>xpp3</groupId>  
  125.             <artifactId>xpp3_min</artifactId>  
  126.         </dependency>  
  127.   
  128.         <dependency>  
  129.             <groupId>org.apache.poi</groupId>  
  130.             <artifactId>poi-ooxml</artifactId>  
  131.         </dependency>  
  132.         <dependency>  
  133.             <groupId>commons-lang</groupId>  
  134.             <artifactId>commons-lang</artifactId>  
  135.         </dependency>  
  136.         <dependency>  
  137.             <groupId>commons-io</groupId>  
  138.             <artifactId>commons-io</artifactId>  
  139.         </dependency>  
  140.         <dependency>  
  141.             <groupId>commons-beanutils</groupId>  
  142.             <artifactId>commons-beanutils</artifactId>  
  143.         </dependency>  
  144.         <dependency>  
  145.             <groupId>org.quartz-scheduler</groupId>  
  146.             <artifactId>quartz</artifactId>  
  147.         </dependency>  
  148.         <dependency>  
  149.             <groupId>org.terracotta.quartz</groupId>  
  150.             <artifactId>quartz-terracotta</artifactId>  
  151.         </dependency>  
  152.         <dependency>  
  153.             <groupId>org.freemarker</groupId>  
  154.             <artifactId>freemarker</artifactId>  
  155.         </dependency>  
  156.         <dependency>  
  157.             <groupId>org.springframework</groupId>  
  158.             <artifactId>spring-context-support</artifactId>  
  159.         </dependency>  
  160.         <dependency>  
  161.             <groupId>org.springframework</groupId>  
  162.             <artifactId>spring-jdbc</artifactId>  
  163.         </dependency>  
  164.         <dependency>  
  165.             <groupId>net.sf.ehcache</groupId>  
  166.             <artifactId>ehcache</artifactId>  
  167.             <type>pom</type>  
  168.         </dependency>  
  169.         <dependency>  
  170.             <groupId>com.haier.openplatform.hfs</groupId>  
  171.             <artifactId>hfs-service-client</artifactId>  
  172.         </dependency>  
  173.         <dependency>  
  174.             <groupId>org.slf4j</groupId>  
  175.             <artifactId>slf4j-log4j12</artifactId>  
  176.         </dependency>  
  177.         <dependency>  
  178.             <groupId>com.ouc.openplatform</groupId>  
  179.             <artifactId>monitor-service-client</artifactId>  
  180.         </dependency>  
  181.         <dependency>  
  182.             <groupId>com.alibaba</groupId>  
  183.             <artifactId>druid</artifactId>  
  184.         </dependency>  
  185.         <dependency>  
  186.             <groupId>com.dangdang</groupId>  
  187.             <artifactId>config-toolkit-easyzk</artifactId>  
  188.         </dependency>  
  189.         <dependency>  
  190.             <groupId>mx4j</groupId>  
  191.             <artifactId>mx4j</artifactId>  
  192.         </dependency>  
  193.         <dependency>  
  194.             <groupId>mx4j</groupId>  
  195.             <artifactId>mx4j-tools</artifactId>  
  196.         </dependency>  
  197.         <dependency>  
  198.             <groupId>com.ouc</groupId>  
  199.             <artifactId>openapi-auth</artifactId>  
  200.         </dependency>  
  201.         <dependency>  
  202.             <groupId>com.ouc</groupId>  
  203.             <artifactId>openapi-service-client</artifactId>  
  204.         </dependency>  
  205.     </dependencies>  
  206. </project>  
    注:当中与ouc相关的包不对外开发。

   2)以安全模块为例,对单一模块的编写进行简单介绍。

   单一模块结构如下图:
   
     (1)advice实例:OperationLogAdvice
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.advice;  
  2.   
  3. import java.util.Date;  
  4.   
  5. import org.aspectj.lang.ProceedingJoinPoint;  
  6.   
  7. import com.ouc.openplatform.log.advice.DefaultOperationLogAdvice;  
  8. import com.ouc.openplatform.log.config.LogConfiguration;  
  9. import com.ouc.openplatform.log.domain.OperationLog;  
  10. import com.ouc.openplatform.security.LoginContext;  
  11. import com.ouc.openplatform.security.LoginContextHolder;  
  12. import com.ouc.openplatform.util.OOPConstant;  
  13. import com.ouc.mkhl.supplier.security.service.OperationLogService;  
  14.   
  15. /**  
  16.  * @author Tom  
  17.  */  
  18. public class OperationLogAdvice extends DefaultOperationLogAdvice {  
  19.     private OperationLogService operationLogService;  
  20.     @Override  
  21.     protected void saveLog(OperationLog operationLog) {  
  22.         operationLogService.save(operationLog);  
  23.     }  
  24.     public void setOperationLogService(OperationLogService operationLogService) {  
  25.         this.operationLogService = operationLogService;  
  26.     }  
  27.       
  28.     protected OperationLog createOperationLog(ProceedingJoinPoint thisJoinPoint,LogConfiguration logConfiguration){  
  29.         LoginContext loginContext = LoginContextHolder.get();  
  30.         if(loginContext == null){  
  31.             loginContext = new LoginContext();  
  32.             loginContext.setUserId(-999L);  
  33.             loginContext.setUserName("-SYSTEM-");  
  34.         }  
  35.         OperationLog operationLog = new OperationLog();  
  36.         operationLog.setAppName(HOPConstant.getAppName());  
  37.         operationLog.setGmtCreate(new Date());  
  38.         operationLog.setGmtModified(new Date());  
  39.         operationLog.setUserId(loginContext.getUserId());  
  40.         operationLog.setUserName(loginContext.getUserName());  
  41.         operationLog.setOperationType(logConfiguration.getType());  
  42.         operationLog.setModule(logConfiguration.getModule());  
  43.         operationLog.setDescription(executeTemplate(getMessage(logConfiguration.getMessageMap()),thisJoinPoint));  
  44.         return operationLog;  
  45.     }  
  46. }  
     (2)dao实例:SupplyUserDAO
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.dao;  
  2.   
  3. import java.util.List;  
  4.   
  5. import com.ouc.mkhl.supplier.security.model.SupplyUser;  
  6.   
  7. public interface SupplyUserDAO {  
  8.       
  9.     public int deleteByPrimaryKey(String supplycode);  
  10.   
  11.     public int insert(SupplyUser record);  
  12.   
  13.     public int insertSelective(SupplyUser record);  
  14.   
  15.     public SupplyUser selectByPrimaryKey(String supplycode);  
  16.   
  17.     public int updateByPrimaryKeySelective(SupplyUser record);  
  18.   
  19.     public int updateByPrimaryKey(SupplyUser record);  
  20.       
  21.     public List<SupplyUser> selectAllSupplyUser();  
  22.       
  23.     public SupplyUser selectByVCode(String supplycode);  
  24.       
  25. }  
     (3)domain实例:OrderNum
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.domain;  
  2.   
  3. public class OrderNum {  
  4.   
  5.     private String itemName; // 项目名  
  6.   
  7.     private int myOrderNum; // 我的订单  
  8.   
  9.     private int proOrderNum; // 订单生产  
  10.   
  11.     private int tstOrderNum; // 订单检测  
  12.   
  13.     private int subOrderNum; // 订单交付  
  14.   
  15.     private String percentage; // 完成率  
  16.   
  17.     public String getItemName() {  
  18.     return itemName;  
  19.     }  
  20.   
  21.     public void setItemName(String itemName) {  
  22.     this.itemName = itemName == null ? null : itemName.trim();  
  23.     }  
  24.   
  25.     public int getMyOrderNum() {  
  26.     return myOrderNum;  
  27.     }  
  28.   
  29.     public void setMyOrderNum(int myOrderNum) {  
  30.     this.myOrderNum = myOrderNum;  
  31.     }  
  32.   
  33.     public int getProOrderNum() {  
  34.     return proOrderNum;  
  35.     }  
  36.   
  37.     public void setProOrderNum(int proOrderNum) {  
  38.     this.proOrderNum = proOrderNum;  
  39.     }  
  40.   
  41.     public int getTstOrderNum() {  
  42.     return tstOrderNum;  
  43.     }  
  44.   
  45.     public void setTstOrderNum(int tstOrderNum) {  
  46.     this.tstOrderNum = tstOrderNum;  
  47.     }  
  48.   
  49.     public int getSubOrderNum() {  
  50.     return subOrderNum;  
  51.     }  
  52.   
  53.     public void setSubOrderNum(int subOrderNum) {  
  54.     this.subOrderNum = subOrderNum;  
  55.     }  
  56.   
  57.     public String getPercentage() {  
  58.     return percentage;  
  59.     }  
  60.   
  61.     public void setPercentage(String percentage) {  
  62.     this.percentage = percentage == null ? null : percentage.trim();  
  63.     }  
  64. }  
     (4)model实例:SupplyUser
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.model;  
  2.   
  3. import java.io.Serializable;  
  4.   
  5. public class SupplyUser implements Serializable{  
  6.   
  7.     private static final long serialVersionUID = -123120032141L;  
  8.       
  9.     private String supplycode;  
  10.   
  11.     private String supplypass;  
  12.   
  13.     private String supplyname;  
  14.   
  15.     public String getSupplycode() {  
  16.         return supplycode;  
  17.     }  
  18.   
  19.     public void setSupplycode(String supplycode) {  
  20.         this.supplycode = supplycode == null ? null : supplycode.trim();  
  21.     }  
  22.   
  23.     public String getSupplypass() {  
  24.         return supplypass;  
  25.     }  
  26.   
  27.     public void setSupplypass(String supplypass) {  
  28.         this.supplypass = supplypass == null ? null : supplypass.trim();  
  29.     }  
  30.   
  31.     public String getSupplyname() {  
  32.         return supplyname;  
  33.     }  
  34.   
  35.     public void setSupplyname(String supplyname) {  
  36.         this.supplyname = supplyname == null ? null : supplyname.trim();  
  37.     }  
  38. }  
    (5)内部Service接口实例:SupplyUserService
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.service;  
  2.   
  3. import java.util.List;  
  4.   
  5. import com.ouc.mkhl.supplier.security.model.SupplyUser;  
  6.   
  7. public interface SupplyUserService {  
  8.       
  9.     public int saveSupplyUser(SupplyUser supplyUser);  
  10.       
  11.     public List<SupplyUser> getAllSupplyUser();  
  12.       
  13.     public SupplyUser getSupplyUserByVCode(String supplycode);  
  14.       
  15. }  
   (6) 内部Service接口实现实例:SupplyUserServiceImpl
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.security.service.impl;  
  2.   
  3. import java.util.List;  
  4.   
  5. import org.springframework.stereotype.Service;  
  6.   
  7. import com.ouc.mkhl.supplier.security.dao.SupplyUserDAO;  
  8. import com.ouc.mkhl.supplier.security.model.SupplyUser;  
  9. import com.ouc.mkhl.supplier.security.service.SupplyUserService;  
  10.   
  11. @Service  
  12. public class SupplyUserServiceImpl implements SupplyUserService {  
  13.   
  14.     private SupplyUserDAO supplyUserDAO;  
  15.   
  16.     public SupplyUserDAO getSupplyUserDAO() {  
  17.     return supplyUserDAO;  
  18.     }  
  19.   
  20.     public void setSupplyUserDAO(SupplyUserDAO supplyUserDAO) {  
  21.     this.supplyUserDAO = supplyUserDAO;  
  22.     }  
  23.   
  24.     @Override  
  25.     public int saveSupplyUser(SupplyUser supplyUser) {  
  26.     int a = supplyUserDAO.insert(supplyUser);  
  27.     return a;  
  28.     }  
  29.   
  30.     @Override  
  31.     public List<SupplyUser> getAllSupplyUser() {  
  32.     System.out.println("进入了biz层impl的getAllSupplyUser");  
  33.     List<SupplyUser> supplyUserList = null;  
  34.     try {  
  35.         supplyUserList = supplyUserDAO.selectAllSupplyUser();  
  36.     } catch (Exception e) {  
  37.         e.printStackTrace();  
  38.     }  
  39.     return supplyUserList;  
  40.     }  
  41.   
  42.     @Override  
  43.     public SupplyUser getSupplyUserByVCode(String supplycode) {  
  44.     SupplyUser supplyUser = null;  
  45.     try {  
  46.         supplyUser = supplyUserDAO.selectByVCode(supplycode);  
  47.     } catch (Exception e) {  
  48.         e.printStackTrace();  
  49.     }  
  50.     return supplyUser;  
  51.     }  
  52. }  

    3)MyBatis配置:

      (1)sqlMapConfig.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE configuration  
  3.   PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  
  4.   "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  5.   
  6. <configuration>  
  7.     <settings>  
  8.         <setting name="cacheEnabled" value="true" />  
  9.         <setting name="lazyLoadingEnabled" value="true" />  
  10.         <setting name="multipleResultSetsEnabled" value="true" />  
  11.         <setting name="useColumnLabel" value="true" />  
  12.         <setting name="useGeneratedKeys" value="false" />  
  13.         <setting name="autoMappingBehavior" value="PARTIAL" />  
  14.         <setting name="defaultExecutorType" value="SIMPLE" /><!-- SIMPLE REUSE BATCH -->  
  15.         <!-- <setting name="defaultExecutorType" value="BATCH" /> -->  
  16.         <setting name="defaultStatementTimeout" value="25000" />  
  17.         <setting name="safeRowBoundsEnabled" value="false" />  
  18.         <setting name="mapUnderscoreToCamelCase" value="false" />  
  19.         <setting name="localCacheScope" value="SESSION" />  
  20.         <!-- <setting name="jdbcTypeForNull" value="OTHER" /> -->  
  21.         <setting name="jdbcTypeForNull" value="NULL" />  
  22.         <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" />  
  23.     </settings>  
  24.     <typeAliases>  
  25.         <!-- =========================================================== -->  
  26.         <!-- security模块 -->  
  27.         <!-- =========================================================== -->  
  28.         <typeAlias alias="supplyUser" type="com.ouc.mkhl.supplier.security.model.SupplyUser"/>  
  29.     </typeAliases>  
  30.       
  31.     <typeHandlers>  
  32.       <typeHandler handler="com.ouc.openplatform.dao.mybatis.SerializableTypeHandler"/>  
  33.     </typeHandlers>  
  34. </configuration>  
     (2)mappers/security/SupplyUserMapper.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >  
  3. <mapper namespace="com.ouc.mkhl.supplier.security.dao.SupplyUserDAO" >  
  4.   <resultMap id="SupplyUserMap" type="supplyUser" >  
  5.     <id column="SupplyCode" property="supplycode" jdbcType="VARCHAR" />  
  6.     <result column="SupplyPass" property="supplypass" jdbcType="VARCHAR" />  
  7.     <result column="SupplyName" property="supplyname" jdbcType="VARCHAR" />  
  8.   </resultMap>  
  9.     
  10.   <sql id="Base_Column_List" >  
  11.     SupplyCode, SupplyPass, SupplyName  
  12.   </sql>  
  13.    
  14.   <select id="selectAllSupplyUser" resultMap="SupplyUserMap">  
  15.     select * from supplyuser  
  16.   </select>  
  17.    
  18.   <select id="selectByVCode" resultType="supplyUser" parameterType="java.lang.String" >  
  19.     select * from supplyuser  
  20.     where SupplyCode = #{supplycode,jdbcType=VARCHAR}  
  21.   </select>  
  22.     
  23.   <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >  
  24.     delete from supplyuser  
  25.     where SupplyCode = #{supplycode,jdbcType=VARCHAR}  
  26.   </delete>  
  27.     
  28.   <insert id="insert" parameterType="supplyUser" >  
  29.     insert into supplyuser (SupplyCode, SupplyPass, SupplyName  
  30.       )  
  31.     values (#{supplycode,jdbcType=VARCHAR}, #{supplypass,jdbcType=VARCHAR}, #{supplyname,jdbcType=VARCHAR}  
  32.       )  
  33.   </insert>  
  34.     
  35.   <insert id="insertSelective" parameterType="supplyUser" >  
  36.     insert into supplyuser  
  37.     <trim prefix="(" suffix=")" suffixOverrides="," >  
  38.       <if test="supplycode != null" >  
  39.         SupplyCode,  
  40.       </if>  
  41.       <if test="supplypass != null" >  
  42.         SupplyPass,  
  43.       </if>  
  44.       <if test="supplyname != null" >  
  45.         SupplyName,  
  46.       </if>  
  47.     </trim>  
  48.     <trim prefix="values (" suffix=")" suffixOverrides="," >  
  49.       <if test="supplycode != null" >  
  50.         #{supplycode,jdbcType=VARCHAR},  
  51.       </if>  
  52.       <if test="supplypass != null" >  
  53.         #{supplypass,jdbcType=VARCHAR},  
  54.       </if>  
  55.       <if test="supplyname != null" >  
  56.         #{supplyname,jdbcType=VARCHAR},  
  57.       </if>  
  58.     </trim>  
  59.   </insert>  
  60.     
  61.   <update id="updateByPrimaryKeySelective" parameterType="supplyUser" >  
  62.     update supplyuser  
  63.     <set >  
  64.       <if test="supplypass != null" >  
  65.         SupplyPass = #{supplypass,jdbcType=VARCHAR},  
  66.       </if>  
  67.       <if test="supplyname != null" >  
  68.         SupplyName = #{supplyname,jdbcType=VARCHAR},  
  69.       </if>  
  70.     </set>  
  71.     where SupplyCode = #{supplycode,jdbcType=VARCHAR}  
  72.   </update>  
  73.     
  74.   <update id="updateByPrimaryKey" parameterType="supplyUser" >  
  75.     update supplyuser  
  76.     set SupplyPass = #{supplypass,jdbcType=VARCHAR},  
  77.       SupplyName = #{supplyname,jdbcType=VARCHAR}  
  78.     where SupplyCode = #{supplycode,jdbcType=VARCHAR}  
  79.   </update>  
  80. </mapper>  

    4)Spring相关配置:

   (1)spring/spring-common.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  3.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"  
  4.     xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"  
  5.     xsi:schemaLocation="  
  6.      http://www.springframework.org/schema/beans   
  7.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  8.      http://www.springframework.org/schema/tx  
  9.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  10.      http://www.springframework.org/schema/aop   
  11.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  12.      http://www.springframework.org/schema/jee   
  13.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  14.      http://www.springframework.org/schema/context  
  15.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  16.      http://www.springframework.org/schema/lang  
  17.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  18.      http://www.springframework.org/schema/util  
  19.      http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
  20.   
  21.      <bean class="com.ouc.mkhl.supplier.util.SystemBootstrap" init-method="init">  
  22.         <property name="httpAdaptor" ref="httpAdaptor" />  
  23.      </bean>  
  24.      <bean class="com.ouc.openplatform.util.SpringApplicationContextHolder"/>  
  25.      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
  26.         <property name="dataSource" ref="dataSource" />  
  27.         <property name="configLocation" value="classpath:/mybatis/sqlMapConfig.xml" />  
  28.         <property name="mapperLocations" value="classpath:/mybatis/**/*Mapper.xml" />    
  29.           
  30.         <property name="typeAliasesPackage" value="com.ouc.mkhl.supplier.security.model" />  
  31.           
  32.     </bean>  
  33.     <bean id="baseDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" abstract="true" lazy-init="true">  
  34.         <property name="sqlSessionFactory" ref="sqlSessionFactory" />  
  35.     </bean>  
  36.       
  37.     <!-- email template config -->  
  38.     <bean id="templateEngine" class="com.ouc.openplatform.template.FreemarkerTemplateEngine">  
  39.         <property name="freeMarkerconfiguration" ref="freeMarkerconfiguration"/>  
  40.     </bean>  
  41.     <bean id="freeMarkerconfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">  
  42.         <property name="templateLoaderPath" value="classpath:/email"/>  
  43.         <property name="freemarkerSettings">  
  44.             <props>  
  45.                 <prop key="template_update_delay">1800</prop><!-- 模板更新延时 -->    
  46.                 <prop key="default_encoding">UTF-8</prop>   
  47.                 <prop key="locale">zh_CN</prop>  
  48.                 <prop key="number_format">0.######</prop>  
  49.             </props>  
  50.         </property>  
  51.     </bean>  
  52.     <bean id="emailBuilder" class="com.ouc.openplatform.hmc.sender.email.DefaultEmailBuilder">  
  53.         <property name="templateEngine" ref="templateEngine"/>  
  54.     </bean>  
  55.       
  56.     <!-- <bean class="com.ouc.openplatform.jmx.JmxMBeanServiceInit">  
  57.         <property name="httpAdapterName" value="httpAdaptor" />  
  58.     </bean> -->  
  59.       
  60.     <bean id="profileAdvice" class="com.ouc.openplatform.console.audit.ProfileAdvice"></bean>  
  61.     <aop:config>  
  62.         <aop:pointcut id="profileAudit" expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..)) or execution(* com.ouc..dao.impl.*DAOImpl.*(..))"/>    
  63.         <aop:aspect ref="profileAdvice" order="5">  
  64.             <aop:before pointcut-ref="profileAudit" method="beforeExecute"/>  
  65.             <aop:after pointcut-ref="profileAudit" method="afterExecute" />  
  66.         </aop:aspect>         
  67.     </aop:config>  
  68. </beans>  
      (2)加载系统信息的类:SystemBootstrap
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. package com.ouc.mkhl.supplier.util;  
  2.   
  3. import java.io.IOException;  
  4. import java.io.InputStream;  
  5. import java.util.Properties;  
  6.   
  7. import mx4j.tools.adaptor.http.HttpAdaptor;  
  8.   
  9. import org.apache.commons.logging.Log;  
  10. import org.apache.commons.logging.LogFactory;  
  11. import org.springframework.beans.factory.InitializingBean;  
  12. import org.springframework.core.env.AbstractEnvironment;  
  13.   
  14. import com.ouc.openplatform.SysException;  
  15. import com.ouc.openplatform.console.audit.AuditInfoCollector;  
  16. import com.ouc.openplatform.session.listener.MaxSessionUtil;  
  17. import com.ouc.openplatform.util.Env;  
  18. import com.ouc.openplatform.util.HOPConstant;  
  19.   
  20. /**  
  21.  * @author Tom  
  22.  */  
  23. public class SystemBootstrap implements InitializingBean {  
  24.     /**  
  25.      * CONFIG_FILE_PATH 系统变量配置文件路径  
  26.      */  
  27.     private static final String CONFIG_FILE_PATH = "/env.properties";  
  28.     private static final Log LOG = LogFactory.getLog(SystemBootstrap.class);  
  29.       
  30.     private HttpAdaptor httpAdaptor;  
  31.   
  32.     public static void  init() {  
  33.         InputStream inputStream = null;  
  34.         Properties properties = new Properties();  
  35.         try{  
  36.             inputStream = SystemBootstrap.class.getResourceAsStream(CONFIG_FILE_PATH);  
  37.             properties.load(inputStream);  
  38.             LOG.info("系统配置项:"+properties);  
  39.         }catch (Exception e) {  
  40.             LOG.error("读取系统配置文件时发生错误:",e);  
  41.             throw new SysException(e);  
  42.         }finally{  
  43.             if(inputStream != null){  
  44.                 try {  
  45.                     inputStream.close();  
  46.                 } catch (IOException e) {  
  47.                     LOG.error("关闭文件输入流失败:",e);  
  48.                 }  
  49.             }  
  50.         }  
  51.         Env.init(properties);  
  52.         AuditInfoCollector.setAppNM(Env.getProperty(Env.KEY_SERVER_NAME));  
  53.         HOPConstant.setAppName(Env.getProperty(Env.KEY_SERVER_NAME));  
  54.         //设置一些全局参数  
  55.         MaxSessionUtil.setMaxSessionKey(Env.getProperty(Env.KEY_SERVER_NAME)+"_MAX_SESSION_KEYS");  
  56.         //使用spring的profile  
  57.         System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, Env.getProperty(Env.ENV_TYPE));  
  58.     }  
  59.   
  60.     @Override  
  61.     public void afterPropertiesSet() throws Exception {  
  62.         httpAdaptor.start();  
  63.     }  
  64.   
  65.     public void setHttpAdaptor(HttpAdaptor httpAdaptor) {  
  66.         this.httpAdaptor = httpAdaptor;  
  67.     }  
  68. }  
     (3)spring/spring-config-toolkit.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.     xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"  
  4.     xsi:schemaLocation="  
  5.      http://www.springframework.org/schema/beans   
  6.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  7.      http://www.springframework.org/schema/lang  
  8.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  9.      http://www.springframework.org/schema/util  
  10.      http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
  11.       
  12.     <bean id="configFactory" class="com.dangdang.config.service.easyzk.ConfigFactory">  
  13.         <constructor-arg name="connectStr" value="${service.config.center.address}" />  
  14.         <constructor-arg name="rootNode" value="/config-center/common" />  
  15.         <constructor-arg name="version" value="1.0" />  
  16.     </bean>  
  17.   
  18.     <bean id="zookeeperSources" class="com.dangdang.config.service.easyzk.support.spring.ZookeeperSourceFactoryProxy" factory-method="create">  
  19.         <constructor-arg name="appName" value="${server.name}" />  
  20.         <constructor-arg name="configFactory" ref="configFactory" />  
  21.         <constructor-arg name="nodes" value=""/>  
  22.     </bean>  
  23.   
  24.     <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">  
  25.         <property name="order" value="1" />  
  26.         <property name="ignoreUnresolvablePlaceholders" value="true" />  
  27.         <property name="location" value="classpath:/application.properties"/>  
  28.     </bean>  
  29.     <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">  
  30.         <property name="order" value="2" />  
  31.         <property name="ignoreUnresolvablePlaceholders" value="true" />  
  32.         <property name="propertySources" ref="zookeeperSources" />  
  33.     </bean>  
  34. </beans>  
     (4) spring/spring-datasource.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
  4.     xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"  
  5.     xmlns:lang="http://www.springframework.org/schema/lang"  
  6.     xsi:schemaLocation="  
  7.      http://www.springframework.org/schema/beans   
  8.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  9.      http://www.springframework.org/schema/tx  
  10.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  11.      http://www.springframework.org/schema/aop   
  12.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  13.      http://www.springframework.org/schema/jee   
  14.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  15.      http://www.springframework.org/schema/context  
  16.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  17.      http://www.springframework.org/schema/lang  
  18.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">  
  19.       
  20.     <bean id="druidStatLoggerProxy" class="com.ouc.openplatform.console.audit.DruidStatLoggerProxy">  
  21.         <property name="sendMessageClient" ref="sendMessageClient" />  
  22.         <property name="enabled" value="${druid.monitor.enable}" />  
  23.     </bean>  
  24.   
  25.     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">  
  26.         <property name="url" value="${datasource.url}" />  
  27.         <property name="username" value="${datasource.name}" />  
  28.         <property name="password" value="${datasource.password}" />  
  29.         <property name="connectionProperties" value="config.decrypt=false" />  
  30.         <property name="filters" value="config,log4j" />  
  31.         <property name="maxActive" value="${datasource.maxActive}" />  
  32.         <property name="initialSize" value="${datasource.initialiSize}" />  
  33.         <property name="maxWait" value="60000" />  
  34.         <property name="minIdle" value="8" />  
  35.         <property name="timeBetweenEvictionRunsMillis" value="10000" />  
  36.         <property name="minEvictableIdleTimeMillis" value="300000" />  
  37.         <property name="validationQuery" value="SELECT 'x' from dual " />  
  38.         <property name="testWhileIdle" value="true" />  
  39.         <property name="testOnBorrow" value="false" />  
  40.         <property name="testOnReturn" value="false" />  
  41.         <property name="poolPreparedStatements" value="true" />  
  42.         <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />  
  43.         <property name="timeBetweenLogStatsMillis" value="${time.between.logstats.millis}" />  
  44.         <property name="statLogger" ref="druidStatLoggerProxy" />  
  45.     </bean>  
  46.       
  47.     <!-- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
  48.         <property name="basePackage" value="com.ouc.mkhl.supplier.security.dao" />  
  49.         <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />  
  50.     </bean> -->  
  51.       
  52. </beans>  
     (5)spring/spring-dubbo.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  4.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  5.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  6.         http://code.alibabatech.com/schema/dubbo  
  7.         http://code.alibabatech.com/schema/dubbo/dubbo.xsd  
  8.         ">  
  9.     <dubbo:application name="${app.name}" />  
  10.     <!-- <dubbo:protocol name="dubbo" port="${dubbo.port}" /> -->  
  11.     <!-- <dubbo:protocol name="rmi" port="1099" /> -->  
  12.     <!-- <dubbo:protocol name="hessian" port="8089" /> -->  
  13.     <!-- <dubbo:protocol name="webservice" port="9999" server="jetty"/> -->  
  14.   
  15.     <!-- 多注册中心配置 -->  
  16.     <dubbo:registry id="qingdaoRegistry" protocol="zookeeper"  
  17.         address="${dubbo.registry.address}" timeout="60000" />  
  18.     <!--  
  19.     <dubbo:registry id="hangzhouRegistry" address="10.21.131.151:9010" default="false" />  
  20.     -->  
  21.   
  22.     <!-- 调用方添加参数 -->  
  23.     <dubbo:consumer>  
  24.         <dubbo:parameter key="almId" value="S00001" />  
  25.     </dubbo:consumer>  
  26.     <!-- 发送监控信息的dubbo服务 -->  
  27.     <dubbo:reference id="sendDubboMessageClient" registry="qingdaoRegistry"  
  28.         owner="hop" interface="com.ouc.openplatform.hmc.client.send.SendMessageClient"  
  29.         version="1.0" protocol="dubbo" timeout="100000" init="true" />  
  30. </beans>  
      (6)spring/spring-external.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  3.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  4.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  5.         http://code.alibabatech.com/schema/dubbo  
  6.         http://code.alibabatech.com/schema/dubbo/dubbo.xsd  
  7.         ">  
  8.     <!-- oop 框架必须接口 begin-->  
  9.     <!-- 文件存储服务 -->  
  10.     <dubbo:reference id="fileServiceClient" registry="qingdaoRegistry" owner="oop" interface="com.ouc.openplatform.hfs.client.service.FileServiceClient" version="1.0.0" protocol="dubbo" timeout="100000" init="true"/>  
  11.       
  12.     <dubbo:reference id="projectServiceClientAdapter" registry="qingdaoRegistry" owner="oop" interface="com.ouc.openplatform.console.project.spi.MonitorServiceClient" version="1.0" protocol="dubbo" timeout="100000" init="false" />  
  13.     <!-- oop 框架必须接口 end-->  
  14. </beans>  
      (7)spring/spring-log.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"  
  4.     xmlns:lang="http://www.springframework.org/schema/lang" xmlns:util="http://www.springframework.org/schema/util"  
  5.     xsi:schemaLocation="  
  6.      http://www.springframework.org/schema/beans   
  7.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  8.      http://www.springframework.org/schema/tx  
  9.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  10.      http://www.springframework.org/schema/aop   
  11.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  12.      http://www.springframework.org/schema/jee   
  13.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  14.      http://www.springframework.org/schema/context  
  15.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  16.      http://www.springframework.org/schema/lang  
  17.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  18.      http://www.springframework.org/schema/util  
  19.      http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
  20.     <!-- 业务日志 -->  
  21.     <bean id="logConfigurationReader" class="com.ouc.openplatform.log.config.LogConfigurationReader">  
  22.         <property name="fileNames">  
  23.             <array>  
  24.                 <value>classpath*:/logs/**/log-*.xml</value>  
  25.             </array>  
  26.         </property>  
  27.     </bean>  
  28.     <bean id="logAdvice" class="com.ouc.mkhl.supplier.security.advice.OperationLogAdvice">  
  29.         <property name="logConfigurationMap">  
  30.             <bean factory-bean="logConfigurationReader" factory-method="getLogConfigurationMap"/>  
  31.         </property>  
  32.         <property name="operationLogService" ref="operationLogService"/>  
  33.     </bean>  
  34.     <bean id="operationLogService" class="com.ouc.mkhl.supplier.security.service.impl.OperationLogServiceImpl">  
  35.         <property name="operationLogDAO" ref="operationLogDAO"/>  
  36.     </bean>  
  37.     <bean id="operationLogDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" parent="baseDAO">  
  38.         <property name="mapperInterface" value="com.ouc.mkhl.supplier.security.dao.OperationLogDAO" />  
  39.     </bean>  
  40.     <aop:config>  
  41.         <aop:pointcut id="daoLog" expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..)) && !execution(* com.ouc..service.impl.OperationLogServiceImpl.*(..))"/>     
  42.         <aop:aspect ref="logAdvice">  
  43.             <aop:around method="advice" pointcut-ref="daoLog"/>  
  44.         </aop:aspect>         
  45.     </aop:config>  
  46. </beans>  
       (8)spring/spring-monitor.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
  4.     xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xmlns:jee="http://www.springframework.org/schema/jee"  
  6.     xmlns:lang="http://www.springframework.org/schema/lang"  
  7.     xsi:schemaLocation="  
  8.      http://www.springframework.org/schema/beans   
  9.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.      http://www.springframework.org/schema/tx  
  11.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  12.      http://www.springframework.org/schema/aop   
  13.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.      http://www.springframework.org/schema/jee   
  15.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  16.      http://www.springframework.org/schema/context  
  17.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  18.      http://www.springframework.org/schema/lang  
  19.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">  
  20.     <!-- quartz监控 -->  
  21.     <bean class="com.ouc.openplatform.console.project.spi.support.OopProjectContextListener">  
  22.         <property name="monitorServiceClient" ref="projectServiceClientAdapter"/>  
  23.     </bean>  
  24. </beans>  
    (9)spring/spring-transaction.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
  4.     xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xmlns:jee="http://www.springframework.org/schema/jee"  
  6.     xmlns:lang="http://www.springframework.org/schema/lang"  
  7.     xsi:schemaLocation="  
  8.      http://www.springframework.org/schema/beans   
  9.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.      http://www.springframework.org/schema/tx  
  11.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  12.      http://www.springframework.org/schema/aop   
  13.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.      http://www.springframework.org/schema/jee   
  15.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  16.      http://www.springframework.org/schema/context  
  17.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  18.      http://www.springframework.org/schema/lang  
  19.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">  
  20.     <!-- Transaction Manager -->  
  21.     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  22.         <property name="dataSource" ref="dataSource" />  
  23.     </bean>  
  24.     <!-- 支持 @Transactional 标记 -->  
  25.     <tx:annotation-driven />  
  26.     <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  27.         <tx:attributes>  
  28.             <tx:method name="find*" propagation="REQUIRED" read-only="true" />  
  29.             <tx:method name="query*" propagation="REQUIRED" read-only="true" />  
  30.             <tx:method name="list*" propagation="REQUIRED" read-only="true" />  
  31.             <tx:method name="search*" propagation="REQUIRED" read-only="true" />  
  32.             <tx:method name="get*" propagation="REQUIRED" read-only="true" />  
  33.             <tx:method name="save*" propagation="REQUIRED" />  
  34.             <tx:method name="update*" propagation="REQUIRED" />  
  35.             <tx:method name="delete*" propagation="REQUIRED" />  
  36.             <tx:method name="create*" propagation="REQUIRED" />  
  37.             <tx:method name="*" propagation="SUPPORTS" />  
  38.         </tx:attributes>  
  39.     </tx:advice>  
  40.     <aop:config proxy-target-class="true">  
  41.         <aop:pointcut id="interceptorPointCuts"  
  42.             expression="execution(* com.ouc..service.impl.*ServiceImpl.*(..))" />  
  43.         <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />  
  44.     </aop:config>  
  45. </beans>  
      (10) spring/security/spring-upload.xml
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
  4.     xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xmlns:jee="http://www.springframework.org/schema/jee"  
  6.     xmlns:lang="http://www.springframework.org/schema/lang"  
  7.     xmlns:util="http://www.springframework.org/schema/util"  
  8.     xsi:schemaLocation="  
  9.      http://www.springframework.org/schema/beans   
  10.      http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  11.      http://www.springframework.org/schema/tx  
  12.      http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  13.      http://www.springframework.org/schema/aop   
  14.      http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  15.      http://www.springframework.org/schema/jee   
  16.      http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  17.      http://www.springframework.org/schema/context  
  18.      http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  19.      http://www.springframework.org/schema/lang  
  20.      http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  21.      http://www.springframework.org/schema/util  
  22.      http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
  23.     <!-- DAO -->  
  24.     <bean id="fileUploadDAO" class="org.mybatis.spring.mapper.MapperFactoryBean" parent="baseDAO">  
  25.         <property name="mapperInterface" value="com.ouc.mkhl.supplier.security.dao.FileUploadDAO" />  
  26.     </bean>  
  27.     <!-- Service -->  
  28.     <bean id="fileUploadService"  
  29.         class="com.ouc.mkhl.supplier.security.service.impl.FileUploadServiceImpl">  
  30.         <property name="fileUploadDAO" ref="fileUploadDAO"/>  
  31.         <property name="fileConstants" ref="fileConstants"/>  
  32.         <property name="fileServiceClientAdapter" ref="fileServiceClientAdapter"/>  
  33.     </bean>  
  34.     <bean id="fileConstants" class="com.ouc.mkhl.supplier.util.FileConstants">  
  35.         <property name="fileSavePath" value="${file.save.path}"/>  
  36.     </bean>  
  37.     <bean id="fileServiceClientAdapter"  
  38.         class="com.ouc.mkhl.supplier.security.service.impl.FileServiceClientAdapterImpl">  
  39.         <property name="fileServiceClient" ref="fileServiceClient"/>  
  40.         <property name="appName" value="MKHL" />  
  41.         <property name="storeSystemAddress" value="${store.system.address}" />  
  42.         <!-- <property name="appName" value="${app.name}" /> -->  
  43.     </bean>  
  44.       
  45.       
  46.     <bean id="fileUploadServiceAop" class="com.ouc.mkhl.supplier.security.util.FileUploadServiceAop"></bean>  
  47.     <aop:config>  
  48.         <aop:pointcut id="fileUploadAudit" expression="execution(* com.ouc..service.impl.FileUploadServiceImpl.*(..))"/>    
  49.         <aop:aspect ref="fileUploadServiceAop" order="5">  
  50.             <aop:before pointcut-ref="fileUploadAudit" method="beforeExecute"/>  
  51.             <aop:after pointcut-ref="fileUploadAudit" method="afterExecute" />  
  52.         </aop:aspect>         
  53.     </aop:config>  
  54. </beans>  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值