Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(前言)

简单介绍一下,本框架的基本功能点:


  1. Spring:整个框架的主体部分,这个自不用说。
  2. SpringMVC:MVC部分我还是比较喜欢Spring的。
  3. MyBatis:选型的时候选择这个ORM主要也是考虑其灵活性的问题,毕竟我也不知道,今后会遇到怎样的需求,用Hibernate一来是不太会用,二来,我还是比较喜欢直接写SQL来的简单一点。
  4. SpringSecurity:这个主要是安全框架,负责用户登录验证及整站权限分配的相关事项(权限分配真的很有用,这个我就不多说了)。
  5. EhCache:一个非常流行又非常简单好用的缓存框架,并且目前已经支持分布式,如果觉得不好用,自己换成Redis也都OK。
  6. JCaptcha:一个简单的验证码生成框架(或者说工具)。
  7. Log4J:现在没人不知道这个日志框架吧...

  按照这样的选型,基本可以完成大部分网站的基础框架,如:

  1. 用户登录管理,
  2. 整站权限分配,
  3. 数据缓存,
  4. 登录验证码,
  5. 数据库操作,
  6. 统一异常处理,
  7. 日志输出。

  网上找了很多文章,大部分都是只有部分整合的,比如SSH整合,SSM整合,SpringMVC+SpringSecurity,等等,东一块,西一块,非常分散,而且每个人的配置方式还不一样,不统一,有的人喜欢注解配置,有的人喜欢XML配置,有的文章甚至直接就是有东没西,神龙见首不见尾。看的我是很郁闷,很蛋疼,因为当我好不容易搭好一个SSM框架,我发现,我要管理用户登录及权限分配的时候,咦,我还得去配置Security,然后又要找很多文章来补充知识,配置Security的时候,又要找验证码的框架,都搞好了以后,发现诶,缓存这个东西不都是任何一个网站必备的吗?所以就有了现在这篇文章,花了好大得劲,终于把所有都整合起来了。

但是,本文章,不提供项目源码!

只有自己亲手走过一遍,才真正学得会知识。作为一个程序员,我相信这样才是对我们是最好的一个方式。所以不要索要源码,不会给的。 先给出整个项目的

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.magic.rent</groupId>
  <artifactId>ssm</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>ssm Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <repositories>
    <repository>
      <id>atlassian</id>
      <name>atlassian</name>
      <url>http://maven.jahia.org/maven2/</url>
    </repository>
  </repositories>
  <build>
    <finalName>ssm</finalName>
    <plugins>
      <!--Mybatis 逆向工程插件-->
      <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
          <verbose>true</verbose>
          <overwrite>true</overwrite>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <properties>
    <security.version>4.1.3.RELEASE</security.version>
    <spring.version>4.3.3.RELEASE</spring.version>
  </properties>
  <dependencies>
    <!-- SpringFramework Start -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-oxm</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-expression</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <!-- SpringFramework End -->
    <!--SpringSecurity Start-->
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
      <version>${security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>${security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>${security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>${security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-crypto</artifactId>
      <version>${security.version}</version>
    </dependency>
    <!--SpringSecurity End-->
    <!--aspectj start-->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.8.6</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.8.6</version>
    </dependency>
    <!--aspectj end-->
    <!--c3p0-->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.1</version>
    </dependency>
    <!--servlet/jsp api start-->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.1</version>
      <scope>provided</scope>
    </dependency>
    <!--servlet/jsp api end-->
    <!--junit4-->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <!--Mybatis-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.3.0</version>
    </dependency>
    <!--Mybatis Spring整合-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.3</version>
    </dependency>
    <!--MySQL Driver-->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.6</version>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!--JCaptcha验证码-->
    <dependency>
      <groupId>com.octo.captcha</groupId>
      <artifactId>jcaptcha</artifactId>
      <version>1.0</version>
    </dependency>
    <!--公共工具包-->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.4</version>
    </dependency>
    <!--Ehcache缓存框架 start-->
    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>2.6.11</version>
    </dependency>
    <!--Mybatis-Ehcache整合包-->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-ehcache</artifactId>
      <version>1.0.0</version>
    </dependency>
    <!--Ehcache-Web页面及对象缓存-->
    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-web</artifactId>
      <version>2.0.4</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.6.2</version>
    </dependency>
    <!--Ehcache缓存框架 end-->
  </dependencies>
</project>
上一篇:python中str和byte的相互转化


下一篇:【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(四)