Spring4.0.9+SpringMVC4.0.9+SpringSecurity3.2.5+MyBatis3.2.5+Activiti5.21即:SSM框架的企业级搭建

前言大纲:

经过两年多的实际开发,感觉现在到了一个瓶颈。没有什么头绪,所以就打算录一套视频教程给自己梳理一下这两年来的经验与技术,并与大家分享一下。
希望对我自己以后的职业道路能有个清晰的认知,并对刚刚入行的同学们以及和我一样现在有瓶颈又有些技术道路迷惑的人一点帮助,仅此而已。谢谢!
每一期视频教程不超过30分钟。这样既不太长又不太短。

本套视频主要讲解:Spring4.0.9+SpringMVC4.0.9+SpringSecurity3.2.5+MyBatis3.2.5+Activiti5.21即:SSM框架的企业级搭建(可二次开发) (如果有可能还会加入消息中间件ActiveMQ)
本套视频致力于为广大程序员提供一个快捷的学习途径和供有想法的人进行项目的二次开发
注:在本套视频讲解如果因本人的水平不够亦或者讲的不对请大家指正(本人QQ:1728709667)
    视频和博客尽可能每周一更新或者间距更短,最近因项目时间紧任务重所以总在加班,希望看博客或是的童鞋们见谅啦!

视频第一讲:(配套博客CSDN)

1、第一讲主要告诉大家spring、springSecurity、mybatis的下载途径;
   spring4.0.9相关jar包下载网址:http://repo.spring.io/release/org/springframework/spring/
   springSecurity3.2.5相关jar包下载网址: http://repo.spring.io/release/org/springframework/spring/
   mybatis3.2.5相关jar包下载网址: https://github.com/mybatis/mybatis-3/releases

2、在下载好相关jar的基础上,开始创建项目引入相关jar包;
    2.1/创建项目
      (在创建项目之前先要确定编码规则,以及这个包(文件夹)的功能及其作用)
       创建一个名为ssm的项目名称
       在项目下分别有两个文件夹:src(存放项目源码)、config(存放项目配置文件)
       src下创建包名为:com.xxx.ssm(公司+项目名称或再加上项目组名称)
        在其下分别为:action:存放mvc视图方法跳转类
                       annotation:存放自定义注解
                       constant:存放自定义常量
                      dao:存放数据持久化相关类
                      interceptor:存放自定义拦截器
                      listener:存放自定义监听器
                      model:存放实体对象
                      security:存放安全验证相关类
                      service:存放服务层接口
                      utils:存放相关工具类
        WebContent下:建立resources文件夹(用于存放相关资源文件) 
                        resources下分别为:
                          common:存放公用资源文件
css:存放css样式表
images:存放图片
js:存放系统前台框架js
userdefinejs:存放自定义js文件
resources.jsp: 引入相关 css js 文件

       WEB-INF下:分为lib文件夹(存放相关依赖jar包)  view文件夹(存放jsp页面)
   2.2/引入jar包:
       spring及其SpirngMVC相关jar,这里截图:
        
        springSecurity相关jar,这里截图:
            
        mybatis相关jar,这里截图:
          
 
       sqlserver mybatis-spring,mybatis-ehache 等相关jar:
           
         
               其他相关依赖jar包其中包含(dwr,hibernate-validate,commons,json等,请根据实际情况添加):
         
   
         项目所需jar包截图:
                       

3、配置好相关project的配置文件(properties文件);
    3.1/  beans-datasource.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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:cache="http://www.springframework.org/schema/cache" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
    http://www.springframework.org/schema/cache   
    http://www.springframework.org/schema/cache/spring-cache.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring  
    http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd
  ">
  <!-- 注入方式可以用annotation -->
  <context:annotation-config />
  <!-- 自动检测需要注册对象的包  -->
  <context:component-scan base-package="com.xxx">
     <!--制定扫包规则,不扫描@Controller注解的JAVA类,其他的还是要扫描  -->
     <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
  </context:component-scan>
  <!-- 允许注解方式的AOP -->
  <aop:aspectj-autoproxy/>
  <!-- 引入外部properties文件  -->
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="locations">
         <list>
           <!-- 这里支持多种寻址方式:classpath和file推荐使用file的方式引入,这样可以将配置和代码分离  -->
           <value>classpath:jdbc.properties</value>
           <value>classpath:sysconfig.properties</value>
         </list>
     </property>
  </bean>
  <!-- 注入数据源  -->
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
     <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <!-- 池启动时创建的连接数量 -->
        <property name="initialSize" value="${jdbc.initialSize}" />
        <!-- 最大连接数据库连接数,设 0 为没有限制  -->
        <property name="maxActive" value="${jdbc.maxActive}" />
        <!-- 最大等待连接中的数量,设 0 为没有限制  -->
        <property name="maxIdle" value="${jdbc.maxIdle}" />
        <!-- 最大等待毫秒数, 单位为 ms, 超过时间会出错误信息 -->
        <property name="maxWait" value="${jdbc.maxWait}" />
  </bean>
    <!-- 配置ehcache的二级缓存策略 -->
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" 
          p:cacheManager-ref="ehcache"/>
    <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
          p:configLocation="classpath:ehcache.xml" p:shared="true"/>
          
  <!-- 创建SqlSessionFactory,同时指定数据源   -->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
     <property name="dataSource" ref="dataSource"/>
     <property name="configLocation" value="classpath:mybatis.xml"/>
     <!-- 自动扫描需要定义类别名的包,将包内的JAVA类的类名作为类别名 -->
     <property name="typeAliasesPackage" value="com.xxx.ssm.model"></property> 
  </bean>
  <!-- 注解方式配置事物  使用声明式事务 transaction-manager:引用上面定义的事务管理器    -->
   <!--  <tx:annotation-driven transaction-manager="transactionManager" /> -->
  <!-- 配置事务管理器    DataSourceTransactionManager dataSource:引用上面定义的数据源  -->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     <property name="dataSource" ref="dataSource" />
  </bean>
  <!-- 定义个通知,指定事务管理器 -->
  <tx:advice id="txAdvice" transaction-manager="transactionManager">
     <tx:attributes >
         <tx:method name="*" propagation="REQUIRED" read-only="false" rollback-for="Throwable" />
        <tx:method name="load*" propagation="SUPPORTS" read-only="true"/>
        <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
        <tx:method name="search*" propagation="SUPPORTS" read-only="true"/>
        <tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
        <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>
        <tx:method name="get*" propagation="SUPPORTS" read-only="true"/> 
     </tx:attributes>
  </tx:advice>
   <aop:config  expose-proxy="true">
        <aop:pointcut id="transactionPointCut"
        expression="execution(* com.xxx.*.service..*.*(..))" />
        <aop:advisor pointcut-ref="transactionPointCut"
            advice-ref="txAdvice" order="1" />
    </aop:config>
  <bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="">  
       <!--  <constructor-arg index="0" ref="sqlSessionFactory"/>   -->
       <constructor-arg index="0" ref="sqlSessionFactory" />
  </bean>
  <!-- Mapper接口所在包名,Spring会自动查找其下的类  自动扫描所有的Mapper接口与文件  -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
      <property name="basePackage" value="com.xxx.ssm.dao.*" />
      <property name="sqlSessionTemplateBeanName" value="sessionTemplate"></property>
  </bean>
  
</beans>
    ------------------------------------------------------------------------------------------------        3.2/   beans-mapper.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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:cache="http://www.springframework.org/schema/cache" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
    http://www.springframework.org/schema/cache   
    http://www.springframework.org/schema/cache/spring-cache.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
  "> 
  
 
</beans>
--------------------------------------------------------------------------------------------------
3.3/   beans-security.xml
--------------------------------------------------------------------------------------------------
  暂时不做这块
--------------------------------------------------------------------------------------------------
3.4/   ehcache.xml
--------------------------------------------------------------------------------------------------
      <? xml version="1.0" encoding="UTF-8" ?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false">    
    <!--
                      设置缓存文件 .data 的创建路径。
                      如果该路径是 Java 系统参数,当前虚拟机会重新赋值。
                      下面的参数这样解释:
        user.home – 用户主目录
        user.dir      – 用户当前工作目录
        java.io.tmpdir – 默认临时文件路径,就是在tomcattemp目录
     -->
    <diskStore path="java.io.tmpdir"/>
    <!-- 缓存位置可以是自定义的硬盘地址也可以是JVM默认使用的缓存地址 -->
    <!--<diskStore path="d:\cache"/> -->   
   <!--   配置自定义缓存  
    name:Cache的唯一标识        
    maxElementsInMemory:缓存中允许创建的最大对象数        
    maxElementsOnDisk:磁盘中最大缓存对象数,若是0表示无穷大        
    eternal:Element是否永久有效,一但设置了,timeout将不起作用,对象永不过期。       
    timeToIdleSeconds:缓存数据的钝化时间,也就是在一个元素消亡之前,                    
            两次访问时间的最大时间间隔值,这只能在元素不是永久驻留时有效,                    
            如果该值是 0 就意味着元素可以停顿无穷长的时间。        
    timeToLiveSeconds:缓存数据的生存时间,也就是一个元素从构建到消亡的最大时间间隔值,                               这只能在元素不是永久驻留时有效,如果该值是0就意味着元素可以停顿无穷长的时间。        
    overflowToDisk:内存不足时,是否启用磁盘缓存。        
    diskPersistent:是否缓存虚拟机重启期数据 
    diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒    
    diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区        
    memoryStoreEvictionPolicy:缓存满了之后的淘汰算法。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)        
    <cache name="SimplePageCachingFilter"         
        maxElementsInMemory="10000"         
        eternal="false"        
        overflowToDisk="false"         
        timeToIdleSeconds="900"         
        timeToLiveSeconds="1800"        
        memoryStoreEvictionPolicy="LFU" />    -->
    <defaultCache name="org.taha.cache.METHOD_CACHE" 
        eternal="false"   
           maxElementsInMemory="10000"  
           overflowToDisk="false"   
           diskPersistent="false"   
           timeToIdleSeconds="0"  
           timeToLiveSeconds="600"   
           memoryStoreEvictionPolicy="LRU" />
</ehcache>
-----------------------------------------------------------------------------------------------------------------------------------------
3.5/  jdbc.properties
--------------------------------------------------------------------------------------------------------------------------------------
      #jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@localhost:1521:ORCL
#jdbc.username=cms
#jdbc.password=123456
#jdbc.Driver=oracle.jdbc.driver.OracleDriver
#connection pool Max count
#dbc.maxActive=10 
#Waiting for the connection Max count
#jdbc.maxIdle=0 
#jdbc.initialSize=5
#jdbc.maxWait=1000
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc\:sqlserver\://localhost\:1433;DatabaseName=ssm
jdbc.username=sa
jdbc.password=123456
jdbc.Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#connection pool Max count
jdbc.maxActive=10 
#Waiting for the connection Max count
jdbc.maxIdle=0 
jdbc.initialSize=5
jdbc.maxWait=1000
jdbc.type=orcale
--------------------------------------------------------------------------------------------------
3.6/ log4j.properties
-------------------------------------------------------------------------------------------------
      #
# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
#
# The five logging levels used by Log are (in order):
#
#   1. DEBUG (the least serious)
#   2. INFO
#   3. WARN
#   4. ERROR
#   5. FATAL (the most serious)
# Set root logger level to ERROR and append to stdout
log4j.rootLogger=all, stdout, Platform, db, FILE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%t](%c:%L) %x- %m%n
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=ERROR
log4j.logger.org.apache.log4j=ERROR
# OpenSymphony Stuff
log4j.logger.com.opensymphony=ERROR
# Spring Stuff
log4j.logger.org.springframework=INFO
log4j.logger.org.hibernate=WARN
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.FILE.File=${catalina.home}/logs/ALESP/ALESP_sys_runtime_log.log
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%t](%c:%L) %x- %m%n
                  
                  
                  
                  
-------------------------------------------------------------------------------------------------

 4、运行项目没问题,开始准备下一讲;
  
 给大家先看一下教程结束最终的项目界面:(基于rabc的权限控制(细粒度控制到按钮级别的))
  
            
(我的运行环境为:java1.7.0_45,apache-tomcat-7.0.63,数据库:sqlserver2008R2
  PS:目前加博主qq的很多了,所以博主打算成立一个关于SSM系统集成的QQ群,如果同意,请留言回复,没有回复暂时不开通QQ群,另外博主原打算连载博客,但是由于项目工期太近最近一直未有更新,视频也没有来得及录制,还请谅解。
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 20
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值