Maven+Spring+Mybatis+Security+Mysql简短的框架

一段时间想搞个框架做开发,但是网上好多代码建立的都太杂乱。有的开源的东西我感觉用不了。本人太笨,不懂怎么上传到github上,就写在博客里,留作记录。以后用的时候也方便。

1.首先让我们看一下项目结构

2.下面是maven的pom.xml文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Excel</groupId>
  <artifactId>excel</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>excel Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
    <!-- 全局版本控制-->
    <spring-version>4.0.2.RELEASE</spring-version>
    <spring-security-version>3.2.5.RELEASE</spring-security-version>
    <mybatis-version>3.2.8</mybatis-version>
  </properties>
  <dependencies>
    <dependency>
      <!-- junit测试包,如果是测试spring框架用不到,使用下面专门的junit-->
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.webflow</groupId>
      <artifactId>spring-webflow</artifactId>
      <version>2.4.0.RELEASE</version>
    </dependency>
    <dependency>
      <!-- springMVC的依赖包,不需要单独导入网上说的那些其他的包
      Spring flow 集成了spring mvc
      -->
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <!-- mybatis包 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.2.8</version>
    </dependency>
    <!-- mysql包 -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.18</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.16</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.2</version>
    </dependency>
    <!-- 版本1.10说明 准备加入至今学spring -security -->
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>${spring-security-version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>3.2.5.RELEASE</version>
    </dependency>
    <!-- jsp页面使用的security 标签  页面级别控制用的到,
-->
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>3.2.5.RELEASE</version>
    </dependency>
    <!-- jsr250 安全机制
本例子使用的权限控制方式
-->
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>jsr250-api</artifactId>
      <version>1.0</version>
    </dependency>

    <!--
    传说中比dbcp牛逼的数据源
    阿里巴巴 德鲁伊
    -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.0.13</version>
    </dependency>


    <dependency>
      <!-- 用于spring 框架的junit测试用的(基于弄快测试的编程)-->
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
      <!--spring自己提供的数据源,-->
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <!-- jsp页面使用的security 标签 -->
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>3.2.5.RELEASE</version>
    </dependency>
    <dependency>
      <!--jstl标签,使得jsp可以使用jstl表达式-->
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>3.0-alpha-1</version>
     </dependency>


  </dependencies>
  <build>
    <finalName>excel</finalName>
  </build>
</project>

3.现在开始配置文件,首先是spring的配置文件

springmvc.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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.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">

       <context:component-scan base-package="spring.security.maven">
              <context:include-filter type="annotation"
                                      expression="org.springframework.stereotype.Controller"/>
              <context:include-filter type="annotation"
                                      expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
       </context:component-scan>
       <context:annotation-config />
       <mvc:annotation-driven></mvc:annotation-driven>
<!--资源文件不拦截-->
       <mvc:default-servlet-handler/>
       <bean id="viewResolver"
             class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix">
                     <value>/WEB-INF/</value>
              </property>
              <property name="suffix">
                     <value>.jsp</value>
              </property>
       </bean>
       <!--配置 使用视图的名字来解析视图
       通过order属性进行定义视图解析器的优先级,值越小优先越高
       InternalResourceViewResolver 只是最大的数值
       -->
       <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
              <property name="order" value="100" />
       </bean>
</beans>
        

然后是 spring_security.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:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-3.2.xsd">
       <!--  Spring-Security 的配置 -->
       <security:http pattern="/css/**" security="none"></security:http>
       <security:http pattern="/img/**" security="none"></security:http>
       <security:http pattern="/js/**" security="none"></security:http>
       <security:http pattern="/fonts/**" security="none"></security:http>
       <security:http pattern="/jsp/**" security="none"></security:http>
       <security:http auto-config="true"  use-expressions="true"  access-denied-page="/denied.jsp" >
              <security:intercept-url pattern="/login.jsp*"  access="permitAll"  />
              <security:intercept-url pattern="/user/admin/**" access="hasRole('ROLE_ADMIN')"/>
              <security:intercept-url pattern="/user/common/**"  access="hasRole('ROLE_USER')" />
              <security:intercept-url pattern="/**" access="permitAll"/>
              <security:form-login login-page="/login.jsp"
                                   authentication-failure-url="/login.jsp?login_error=true"
                                   default-target-url="/index.jsp"
                      />

              <!--成功退出后跳转到的页面 -->
              <security:logout logout-success-url="/login.jsp" />
              <!-- 配置会话超时跳转的页面,tomacat默认30分钟过时-->
              <security:session-management invalid-session-url="/sessionOutTime.jsp">
                     <!-- 单点登陆,这个会导致前一个登陆失效
                     error-if-maximum-exceeded 阻止第二次登陆
                     -->
                 <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="true"></security:concurrency-control>
              </security:session-management>
       </security:http>
       <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename"  value="message" />
       </bean>

       <!--使用了annotations保护业务方法
         可以接口出添加    @RolesAllowed("ROLE_ADMIN")
         -->
       <security:global-method-security
               jsr250-annotations="enabled" secured-annotations="enabled" >
       </security:global-method-security>


       <!-- 配置權限 -->
       <security:authentication-manager>
              <security:authentication-provider  user-service-ref="managerDetialService">
                     <!-- 对于密码的MD5加密 -->
                     <security:password-encoder ref="passwordEncoder">
                            <!-- 加盐
                            对应的加盐值方式是 密码{盐值}
                            结果是小写的
                            例如 用户名字wpj 密码123
                            加密方式是 123{wpj} 去MD5值
                            -->
                            <security:salt-source user-property="username"/>

                     </security:password-encoder>
              </security:authentication-provider>

       </security:authentication-manager>
       <bean id="securityFilterChainProxy" class="org.springframework.security.web.FilterChainProxy">
              <constructor-arg>
                     <list>
                            <security:filter-chain pattern="/css/**"
                                                   filters="none" />
                            <security:filter-chain pattern="/images/**"
                                                   filters="none" />
                            <security:filter-chain pattern="/js/**"
                                                   filters="none" />
                            <security:filter-chain pattern="/font/**"
                                                   filters="none" />
                             <security:filter-chain pattern="/jsp/**"
                                                   filters="none" />
                     </list>
              </constructor-arg>
       </bean>
       <!-- 加密 -->
       <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder">
       </bean>
</beans>

后面是spring-mybatis.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: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/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">

    <!-- 自动扫描(自动注入) -->
    <context:component-scan base-package="spring.security.maven">
        <context:exclude-filter type="annotation"
                                expression="org.springframework.stereotype.Controller"/>
        <context:exclude-filter type="annotation"
                                expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>
    <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <!-- 这里支持多种寻址方式:classpath和file -->
                <!-- 推荐使用file的方式引入,这样可以将配置和代码分离 -->
                <value>classpath:db.properties</value>
                <value>classpath:message_zh_CH.properties</value>
            </list>
        </property>
    </bean>
    <!-- spring与mybatis整合配置,扫描所有dao -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="spring.security.maven.dao" />
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    </bean>
    <!-- mybatis文件配置,扫描所有mapper文件 -->
    <bean id="sqlSessionFactory"
          class="org.mybatis.spring.SqlSessionFactoryBean"
          p:dataSource-ref="dataSource"
          p:mapperLocations="classpath:Mapper/*Mapper.xml"
            />
    <!--p:mapperLocations="classpath:spring/security/maven/daomain/*Mapper.xml" 部署时候用的 Mapper测试时候用的-->
    <!-- configLocation为mybatis属性 mapperLocations为所有mapper-->



    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
             destroy-method="close" >
              <property name="driverClassName">
                     <value>${driver}</value>
              </property>
              <property name="url">
                     <value>${url}</value>
              </property>
              <property name="username">
                     <value>${username}</value>
              </property>
              <property name="password">
                     <value>${password}</value>
              </property>
              <!-- 连接池最大使用连接数 -->
              <property name="maxActive">
                     <value>20</value>
              </property>
              <!-- 初始化连接大小 -->
              <property name="initialSize">
                     <value>1</value>
              </property>
              <!-- 获取连接最大等待时间 -->
              <property name="maxWait">
                     <value>60000</value>
              </property>
              <!-- 连接池最大空闲 -->
              <property name="maxIdle">
                     <value>20</value>
              </property>
              <!-- 连接池最小空闲 -->
              <property name="minIdle">
                     <value>3</value>
              </property>
              <!-- 自动清除无用连接 -->
              <property name="removeAbandoned">
                     <value>true</value>
              </property>
              <!-- 清除无用连接的等待时间 -->
              <property name="removeAbandonedTimeout">
                     <value>180</value>
              </property>
              <!-- 连接属性 -->
              <property name="connectionProperties">
                     <value>clientEncoding=UTF-8</value>
              </property>
       </bean>
    <!-- 配置事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 注解方式配置事物 -->
    <tx:annotation-driven transaction-manager="transactionManager" />
    <!-- 拦截器方式配置事物 -->
    <tx:advice id="transactionAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="append*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="modify*" propagation="REQUIRED" />
            <tx:method name="edit*" propagation="REQUIRED" />
            <tx:method name="delete*" propagation="REQUIRED" />
            <tx:method name="remove*" propagation="REQUIRED" />
            <tx:method name="repair" propagation="REQUIRED" />
            <tx:method name="delAndRepair" propagation="REQUIRED" />

            <tx:method name="get*" propagation="SUPPORTS" />
            <tx:method name="find*" propagation="SUPPORTS" />
            <tx:method name="load*" propagation="SUPPORTS" />
            <tx:method name="search*" propagation="SUPPORTS" />
            <tx:method name="datagrid*" propagation="SUPPORTS" />

            <tx:method name="*" propagation="SUPPORTS" />
        </tx:attributes>
    </tx:advice>
    <bean id="contentManager"
          class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
        <property name="favorPathExtension" value="true"/>
        <property name="ignoreAcceptHeader" value="true" />
        <property name="defaultContentType" value="text/html" />
        <property name="useJaf" value="false"/>
        <property name="mediaTypes">
            <map>
                <entry key="json" value="application/json" />
                <entry key="html" value="text/html" />
                <entry key="xml" value="application/xml" />
            </map>
        </property>
    </bean>
</beans>

4.数据库配置文件

db.properties

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/spring_security?useUnicode=true&amp;characterEncoding=UTF-8
username=root
password=root

5.日志文件

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 WARN and append to stdout
log4j.rootLogger=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
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 %5p (%c:%L) - %m%n

# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=FATAL

#log4j.logger.com.opensymphony.xwork2=DEBUG
#log4j.logger.org.apache.struts2=DEBUG

5.消息转码文件

message_zh_CH.properties

AbstractAccessDecisionManager.accessDenied=\u4E0D\u5141\u8BB8\u8BBF\u95EE
AbstractLdapAuthenticationProvider.emptyPassword=\u574F\u7684\u51ED\u8BC1
AbstractSecurityInterceptor.authenticationNotFound=\u672A\u5728SecurityContext\u4E2D\u67E5\u627E\u5230\u8BA4\u8BC1\u5BF9\u8C61
AbstractUserDetailsAuthenticationProvider.badCredentials=\u574F\u7684\u51ED\u8BC1
AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
AbstractUserDetailsAuthenticationProvider.disabled=\u7528\u6237\u5DF2\u5931\u6548
AbstractUserDetailsAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
AbstractUserDetailsAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
AbstractUserDetailsAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken
AccountStatusUserDetailsChecker.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
AccountStatusUserDetailsChecker.disabled=\u7528\u6237\u5DF2\u5931\u6548
AccountStatusUserDetailsChecker.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
AccountStatusUserDetailsChecker.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
AclEntryAfterInvocationProvider.noPermission=\u7ED9\u5B9A\u7684Authentication\u5BF9\u8C61({0})\u6839\u672C\u65E0\u6743\u64CD\u63A7\u9886\u57DF\u5BF9\u8C61({1})
AnonymousAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684AnonymousAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
BindAuthenticator.badCredentials=\u574F\u7684\u51ED\u8BC1
BindAuthenticator.emptyPassword=\u574F\u7684\u51ED\u8BC1
CasAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684CasAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
CasAuthenticationProvider.noServiceTicket=\u672A\u80FD\u591F\u6B63\u786E\u63D0\u4F9B\u5F85\u9A8C\u8BC1\u7684CAS\u670D\u52A1\u7968\u6839
ConcurrentSessionControlStrategy.exceededAllowed=\u5DF2\u7ECF\u8D85\u8FC7\u4E86\u5F53\u524D\u4E3B\u4F53({0})\u88AB\u5141\u8BB8\u7684\u6700\u5927\u4F1A\u8BDD\u6570\u91CF
DigestAuthenticationFilter.incorrectRealm=\u54CD\u5E94\u7ED3\u679C\u4E2D\u7684Realm\u540D\u5B57({0})\u540C\u7CFB\u7EDF\u6307\u5B9A\u7684Realm\u540D\u5B57({1})\u4E0D\u543B\u5408
DigestAuthenticationFilter.incorrectResponse=\u9519\u8BEF\u7684\u54CD\u5E94\u7ED3\u679C
DigestAuthenticationFilter.missingAuth=\u9057\u6F0F\u4E86\u9488\u5BF9'auth' QOP\u7684\u3001\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0}
DigestAuthenticationFilter.missingMandatory=\u9057\u6F0F\u4E86\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0}
DigestAuthenticationFilter.nonceCompromised=Nonce\u4EE4\u724C\u5DF2\u7ECF\u5B58\u5728\u95EE\u9898\u4E86\uFF0C{0}
DigestAuthenticationFilter.nonceEncoding=Nonce\u672A\u7ECF\u8FC7Base64\u7F16\u7801; \u76F8\u5E94\u7684nonce\u53D6\u503C\u4E3A {0}
DigestAuthenticationFilter.nonceExpired=Nonce\u5DF2\u7ECF\u8FC7\u671F/\u8D85\u65F6
DigestAuthenticationFilter.nonceNotNumeric=Nonce\u4EE4\u724C\u7684\u7B2C1\u90E8\u5206\u5E94\u8BE5\u662F\u6570\u5B57\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0}
DigestAuthenticationFilter.nonceNotTwoTokens=Nonce\u5E94\u8BE5\u7531\u4E24\u90E8\u5206\u53D6\u503C\u6784\u6210\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0}
DigestAuthenticationFilter.usernameNotFound=\u7528\u6237\u540D{0}\u672A\u627E\u5230
JdbcDaoImpl.noAuthority=\u6CA1\u6709\u4E3A\u7528\u6237{0}\u6307\u5B9A\u89D2\u8272
JdbcDaoImpl.notFound=\u672A\u627E\u5230\u7528\u6237{0}
LdapAuthenticationProvider.badCredentials=\u574F\u7684\u51ED\u8BC1
LdapAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F
LdapAuthenticationProvider.disabled=\u7528\u6237\u5DF2\u5931\u6548
LdapAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F
LdapAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A
LdapAuthenticationProvider.emptyUsername=\u7528\u6237\u540D\u4E0D\u5141\u8BB8\u4E3A\u7A7A
LdapAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken
PasswordComparisonAuthenticator.badCredentials=\u574F\u7684\u51ED\u8BC1
#PersistentTokenBasedRememberMeServices.cookieStolen=Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack.
ProviderManager.providerNotFound=\u672A\u67E5\u627E\u5230\u9488\u5BF9{0}\u7684AuthenticationProvider
RememberMeAuthenticationProvider.incorrectKey=\u5C55\u793ARememberMeAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
RunAsImplAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684RunAsUserToken\u4E0D\u542B\u6709\u9884\u671F\u7684key
SubjectDnX509PrincipalExtractor.noMatching=\u672A\u5728subjectDN\: {0}\u4E2D\u627E\u5230\u5339\u914D\u7684\u6A21\u5F0F
SwitchUserFilter.noCurrentUser=\u4E0D\u5B58\u5728\u5F53\u524D\u7528\u6237
SwitchUserFilter.noOriginalAuthentication=\u4E0D\u80FD\u591F\u67E5\u627E\u5230\u539F\u5148\u7684\u5DF2\u8BA4\u8BC1\u5BF9\u8C61

6.说明文档

如果用tomcat 8.0运行该Maven项目 访问地址为:localhost:8080/excel
数据的名称:spring_security
管理员账号:757671834@qq.com
管理员密码:password

普通用户账号:393993507@qq.com
普通用户密码:password

7.数据库相关信息

-- MySQL dump 10.13  Distrib 5.7.9, for Win64 (x86_64)
--
-- Host: localhost    Database: spring_security
-- ------------------------------------------------------
-- Server version    5.7.10-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `t_user`
--

DROP TABLE IF EXISTS `t_user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(80) DEFAULT NULL,
  `user_password` varchar(80) DEFAULT NULL,
  `user_other` varchar(80) DEFAULT NULL,
  `user_role` varchar(80) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `t_user`
--

LOCK TABLES `t_user` WRITE;
/*!40000 ALTER TABLE `t_user` DISABLE KEYS */;
INSERT INTO `t_user` VALUES (1,'757671834@qq.com','abe4420dd6f2242792e291ef1497619d','超级管理员','ROLE_ADMIN'),(2,'393993507@qq.com','3aa6d08e2c3087b2ee52921b6a21ecc6','普通用户','ROLE_USER');
/*!40000 ALTER TABLE `t_user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-03-05 22:44:53

8.最最主要的源码附件

 源码里有两个sql文件,请使用SecurityTwo.sql

....我去?为什么不能增加附件????????????

我只能放到我百度云盘里了。如果有懂得可以跟我说下怎么上传附件

http://pan.baidu.com/s/1ntZdfZV

9.最最重要的,要说明下来源:

这个项目是别人写的,我只是整理数出来。项目是在github上,具体的地址我不记得了。

开源中国里可以搜索到。但是网上代码不全,我补全了,做了一个基本框架。有兴趣的可以留言探讨下。

posted @ 2016-03-07 16:51  魔流剑  阅读(1933)  评论(0编辑  收藏  举报