声明:
本人提供这个 SpringMvc + Mybatis + Redis 的Demo 本着学习的态度,如果有欠缺和不足的地方,
给予指正,并且多多包涵
框架运行环境:
Maven版本:3.3.9
Eclipse版本:MARS.2
JDK版本:1.8
Tocat版本:8.0.36
框架结构:框架全采用maven管理 所以源码只有180KB左右要是不会Maven就请自行补习
annotation:自定义注解 实现的类似于shiro的权限 但是比较简单不喜勿喷 没shiro强大但是比他简单 然
后自己结合RBAC+Redis+ Intercept技术实现的 为什么没用shiro并不是shiro不强大只是不太喜欢那么
复杂的用法 虽然已经很简单了 我是懒得出奇的人 不过还是建议大家多去学习shiro这个权限框架毕竟连
spring都推荐使用Shiro RBAC是一个数据库的设计模型简单理解为:用户-角色-权限-资源 这里不再多
说有个网友帖子写得不错 点击打开链接 拦截器什么滴也不多说spring的核心之一
entity:实体类的父类很简单自己看源码就行
log4j:这里重写了log4j的SMTPAppender这个类 首先说说这个类是干嘛的 他是用来发送邮件的当报错
时邮件通知管理员,具体的请参考我的另一篇博客,上面有详细介绍点击打开链接
mapper:所有mapper的父类 默认提供了几个常用的方法
message:提示语相关的东西 都不知道咋描述 就是为了代码中不允许有一个中文和硬编码的存在 当然
自己也可以改改实现国际化
什么滴都没做只做了返回json这块 连异常都封装成JSon了
tools:看名字就知道一些常用的工具类 有什么身份证、经纬度、日期计算、DES和RSA加密、MD5之类
的东西 具体请看代码类注解 我觉得我注解已经很多了
redis:这里重写了spring-data-redis里面的RedisCache、RedisCachemanager两个类和封装了一些其
他的包目的就是为了实现redis的自动续期和单用户登录功能(一个用户同时只能在一个地方登录)如果
需要实现不同平台的单用户登录需要自己小改一下 在缓存中多加个平台标识就行了
butler:这是web项目 名字不必纠结 介绍下包的作用
service:系统的一些服务类 这里只有定时任务和Spring mail邮件推送服务
system:这个看里面的包就知道干嘛用的了 就说说exception和interception这两个 一个是全局异常一
个是什么实体类校验权限等拦截器
框架的大致结构就介绍到这里 下面说一声配置的xml
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>butler</display-name>
<!-- 声明Spring配置文件所在目录 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext.xml,
classpath*:spring-*.xml
</param-value>
</context-param>
<!-- 声明IntrospectorCleanupListener监听器防止反复加载对象造成内存泄漏 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<!-- 声明ContextLoaderListener监听器自动装配Spring配置文件信息 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 全局UTF-8编码过滤器 -->
<filter>
<filter-name>CharacterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Spring控制器 -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- HttpPutFormContentFilter 使put方法是也可以获取表单内的参数 -->
<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<servlet-name>spring</servlet-name>
</filter-mapping>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
接下来是Spring的主配置文件applicationContext.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:c="http://www.springframework.org/schema/c"
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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<!-- 配置需要交给spring扫描管理的包,一般是包括整个项目的java文件的父包(由context提供) -->
<context:component-scan base-package="org.system,org.service.task" />
<!-- 属性文件读入,用于加密数据库配置文件 -->
<bean id="propertyConfigurer" class="org.system.encrypt.DBConfigurer">
<property name="locations">
<list>
<value>classpath:conf.properties</value>
</list>
</property>
</bean>
<!-- 配置需要交给spring扫描管理的文件,一般是项目的配置文件(由context提供) -->
<context:property-placeholder location="classpath:conf.properties" />
<!-- 配置数据源 -->
<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<!-- 基本配置 -->
<property name="driverClassName" value="${db.driverClassName}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.password}" />
<!-- 初始化时建立物理连接的个数 -->
<property name="initialSize" value="${db.initialSize}" />
<!-- 最小连接池数 -->
<property name="minIdle" value="${db.minIdle}" />
<!-- 最大连接池数量 -->
<property name="maxActive" value="${db.maxActive}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="${db.maxWait}" />
</bean>
<!-- 配置sqlSessionFactory(由mybatis-spring.jar提供支持) -->
<bean name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 配置数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- 配置mybatis的默认选项 -->
<property name="configuration" ref="configuration" />
<!-- 配置拦截器用于Mybatis分页和总数查询,只实现Mysql -->
<property name="plugins" ref="PaginationInterceptor" />
</bean>
<!-- mybatis默认选项配置 -->
<bean id="configuration" class="org.apache.ibatis.session.Configuration">
<property name="callSettersOnNulls" value="true"/>
</bean>
<!-- Mybatis分页拦截器 -->
<bean name="PaginationInterceptor" class="org.system.intercept.PaginationInterceptor" />
<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.system.mapper..*" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<!-- 支持注解事务模式 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<!-- 事务管理 -->
<bean name="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="insert*" propagation="REQUIRED" read-only="false" />
<tx:method name="delete*" propagation="REQUIRED" read-only="false" />
<tx:method name="update*" propagation="REQUIRED" read-only="false" />
<tx:method name="get*" propagation="SUPPORTS" />
</tx:attributes>
</tx:advice>
<!-- 配置该声明式事务规则用于的切入点 步骤: 1.配置切入点 2.应用该声明式事务规则 -->
<aop:config proxy-target-class="true" expose-proxy="true">
<!-- 配置切入点 -->
<aop:pointcut id="transaction_pointcut" expression="execution(* org.system.service.impl..*.*(..))" />
<!-- 应用该声明式事务规则 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="transaction_pointcut" />
</aop:config>
<!-- 异常拦截器 -->
<bean id="exceptionHandler" class="org.system.exception.ExceptionResolver" />
<!-- Spring上下文工具类 -->
<bean id="springContextUtil" class="org.service.utils.spring.SpringContextUtil" />
</beans>
这里说一说有个数据库加密的东西在这里
<!-- 属性文件读入,用于加密数据库配置文件 -->
<bean id="propertyConfigurer" class="org.system.encrypt.DBConfigurer">
<property name="locations">
<list>
<value>classpath:conf.properties</value>
</list>
</property>
</bean>
意思就是用DBConfigurer这个类来解密conf.properties这个文件内的几个配置 就是采用了des加密解
密主要为了防止配置文件泄露数据库的信息暴露 如果不用直接注释掉就可以使用明文了 稍后会把
properties相关文件贴出来
接下来是spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd ">
<!-- 扫描要自动管理的包 -->
<context:component-scan base-package="org.system.controller.impl" />
<!-- 静态资源文件路径设置 -->
<mvc:resources location="/api/" mapping="/api/**" />
<!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 系统内没有涉及到页面跳转所以基本无用-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".html" />
</bean>
<!-- 校验拦截器 -->
<bean id="validInterceptor" class="org.system.intercept.ValidInterceptor"/>
<!-- 配置AOP切点 只拦截Controltroller -->
<aop:config>
<!--切入点 -->
<aop:pointcut id="validPoint" expression="execution(public * org.system.controller.impl..*.*(..))" />
<!--在该切入点使用自定义拦截器 -->
<aop:advisor pointcut-ref="validPoint" advice-ref="validInterceptor" />
</aop:config>
<!--开启这个配置,spring才能识别@Scheduled注解 -->
<task:scheduler id="scheduler" pool-size="10" />
<task:executor id="executor" pool-size="5-10" queue-capacity="200" rejection-policy="CALLER_RUNS" />
<task:annotation-driven executor="executor" scheduler="scheduler" />
<!-- 导入其他配置文件 -->
<import resource="/org/system/config/*.xml" />
</beans>
接下来是spring-mail.xml:这是用来配置Spring Mail发件人信息的 jdk8发布出去原因和解决方案请
点击
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 邮件发送器 -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<!-- 服务器地址 -->
<property name="host" value="${mail.smtp.host}" />
<!-- 服务器端口 -->
<!-- <property name="port" value="${mail.smtp.port}" /> -->
<!--用户名 -->
<property name="username" value="${mail.username}" />
<!-- 用户密码 -->
<property name="password" value="${mail.password}" />
<!-- 默认编码 -->
<property name="defaultEncoding" value="UTF-8"></property>
<!-- 其他配置 -->
<property name="javaMailProperties">
<props>
<!--是否验证密码 -->
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<!-- 超时时间 -->
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
<!-- SSL类配置 -->
<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
</props>
</property>
</bean>
</beans>
接下来是spring-redis.xml:这是配置redis的东西
<?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:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<!-- 支持缓存注解 -->
<cache:annotation-driven cache-manager="cacheManager" />
<!-- redis pool相关配置 -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<!-- 最小空闲数 -->
<property name="minIdle" value="${redis.minIdle}" />
<!-- 最大空闲数 -->
<property name="maxIdle" value="${redis.maxIdle}" />
<!-- 最大连接数 -->
<property name="maxTotal" value="${redis.maxTotal}" />
<!-- 最大等待时间 单位毫秒(ms) -->
<property name="maxWaitMillis" value="${redis.maxWaitMillis}" />
<!-- 使用连接时测试连接是否可用 -->
<property name="testOnBorrow" value="${redis.testOnBorrow}" />
</bean>
<!-- jedis客户端连接工厂 -->
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="poolConfig" ref="poolConfig" />
<property name="database" value="${redis.database}" />
<property name="port" value="${redis.port}" />
<property name="hostName" value="${redis.host}" />
<property name="password" value="${redis.password}" />
</bean>
<!-- redisTemplate模板 -->
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory" />
</bean>
<!-- redis缓存管理器 -->
<bean id="cacheManager" class="org.redis.cache.RedisCacheManager">
<constructor-arg name="redisOperations" ref="redisTemplate" />
<!-- 是否事务提交,如果事务回滚,缓存也回滚,默认false -->
<property name="transactionAware" value="true" />
<!-- 设置缓存超时时间 已实现自动续期 如果不设置将永久存在 -->
<property name="expires">
<map>
<entry key="userCache" value="3600" />
<entry key="permissionCache" value="3600" />
</map>
</property>
</bean>
</beans>
接下来日志的xml也可以使用properties为毛我这里用xml具体原因请参考上文说的关于日志的文章
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<!-- 控制台日志配置 -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%p] [%c{3}] %m%n"/>
</layout>
</appender>
<!-- info级别日志控制 -->
<appender name="info" class="org.apache.log4j.DailyRollingFileAppender">
<!-- 文件路径 -->
<param name="File" value="${catalina.home}/logs/${webapp.root}/infrastructure/info.log" />
<!-- 是否追加 -->
<param name="Append" value="true" />
<!-- 最低日志级别 -->
<param name="Threshold" value="INFO" />
<!-- 回滚日志后缀 -->
<param name="datePattern" value="'.'yyyy-MM-dd" />
<!-- 是否启用缓冲 当缓冲区数据达到一定大小再写入文件 默认8K -->
<!-- <param name="BufferedIO" value="true"/>
<param name="BufferSize" value="8192"/> -->
<!-- 日志输出布局 -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%p] [%c] %m%n" />
</layout>
<!--限制输出级别 -->
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<!-- 最小级别 -->
<param name="LevelMax" value="INFO" />
<!-- 最大级别 -->
<param name="LevelMin" value="INFO" />
</filter>
</appender>
<!-- warn级别日志控制 -->
<appender name="warn" class="org.apache.log4j.DailyRollingFileAppender">
<!-- 文件路径 -->
<param name="File" value="${catalina.home}/logs/${webapp.root}/infrastructure/warn.log" />
<!-- 是否追加 -->
<param name="Append" value="true" />
<!-- 最低日志级别 -->
<param name="Threshold" value="WARN" />
<!-- 回滚日志后缀 -->
<param name="datePattern" value="'.'yyyy-MM-dd" />
<!-- 是否启用缓冲 当缓冲区数据达到一定大小再写入文件 默认8K -->
<!-- <param name="BufferedIO" value="true"/>
<param name="BufferSize" value="8192"/> -->
<!-- 日志输出布局 -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%p] [%c] %m%n" />
</layout>
<!--限制输出级别 -->
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<!-- 最小级别 -->
<param name="LevelMax" value="WARN" />
<!-- 最大级别 -->
<param name="LevelMin" value="WARN" />
</filter>
</appender>
<!-- error级别日志控制 -->
<appender name="error" class="org.apache.log4j.DailyRollingFileAppender">
<!-- 文件路径 -->
<param name="File" value="${catalina.home}/logs/${webapp.root}/infrastructure/error.log" />
<!-- 是否追加 -->
<param name="Append" value="true" />
<!-- 最低日志级别 -->
<param name="Threshold" value="ERROR" />
<!-- 回滚日志后缀 -->
<param name="datePattern" value="'.'yyyy-MM-dd" />
<!-- 是否启用缓冲 当缓冲区数据达到一定大小再写入文件 默认8K -->
<!-- <param name="BufferedIO" value="true"/>
<param name="BufferSize" value="8192"/> -->
<!-- 日志输出布局 -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%p] [%c] %m%n" />
</layout>
<!--限制输出级别 -->
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<!-- 最小级别 -->
<param name="LevelMax" value="ERROR" />
<!-- 最大级别 -->
<param name="LevelMin" value="ERROR" />
</filter>
</appender>
<!-- 发送日志文件到邮件 -->
<appender name="email" class="org.main.log4j.SMTPAppender">
<!-- 最小输出日志级别 -->
<param name="Threshold" value="ERROR" />
<!-- 缓冲Event个数默认512 当达到了多少个就覆盖以前的Event 而非网络上所说的缓冲数据大小 不看源码坑出血 -->
<param name="BufferSize" value="512" />
<!-- 错误个数默认一个 即出现错误就发送邮件 -->
<param name="ErrorSize" value="5" />
<!-- 发送日志的邮箱 -->
<param name="From" value="****@****.com" />
<!-- 发送日志邮箱SMTP -->
<param name="SMTPHost" value="smtp.163.com" />
<!-- 发送日志的邮箱用户名 -->
<param name="SMTPUsername" value="*****@****.com" />
<!-- 发送日志的邮箱密码 现在这里很多邮件都是用了什么授权码-->
<param name="SMTPPassword" value="***********" />
<!-- 日志邮件主题 -->
<param name="Subject" value="后台系统框架异常提醒,请尽快处理" />
<!-- 日志邮件接收者 -->
<param name="To" value="******@qq.com" />
<!-- 抄送邮件接受者 -->
<param name="Bcc" value="*******@outlook.com"/>
<!-- 日志输出布局 -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%p] [%c] %m%n" />
</layout>
</appender>
<!-- 异步发送邮件设置 -->
<appender name="asyncout" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="email" />
</appender>
<!-- 需要特殊处理的日志级别 -->
<logger name="org.springframework">
<level value="WARN" />
</logger>
<logger name="org.system">
<level value="DEBUG" />
</logger>
<!-- 根路径设置 -->
<root>
<level value="INFO" />
<appender-ref ref="console" />
<appender-ref ref="info" />
<appender-ref ref="warn" />
<appender-ref ref="error" />
<appender-ref ref="asyncout" />
</root>
</log4j:configuration>
最后一个butler.xml:权限部分注释了 想要测试放开取消注释即可
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 指定自己定义的validator -->
<mvc:annotation-driven validator="validator">
<mvc:message-converters register-defaults="true">
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json;charset=UTF-8" />
<property name="features">
<array>
<value>WriteMapNullValue</value>
<value>WriteNullStringAsEmpty</value>
</array>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 以下 validator ConversionService 在使用 mvc:annotation-driven 会 自动注册 -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
<!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties -->
<property name="validationMessageSource" ref="messageSource" />
</bean>
<!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:org/system/config/valid</value>
</list>
</property>
<property name="useCodeAsDefaultMessage" value="false" />
<property name="defaultEncoding" value="UTF-8" />
<property name="cacheSeconds" value="60" />
</bean>
<!-- <mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="org.system.intercept.SecurityInterceptor" />
</mvc:interceptor>
</mvc:interceptors> -->
</beans>
最后是conf.properties
这里加密的几个对应得明文分别是
url:jdbc:MySQL://localhsot:3306/butler?useUnicode=true&characterEncoding=utf8&mysqlEncoding=utf8
user:root
password:123456
如果对应的没变化就不需要改 后面提供的框架源码这块都会是错的请谅解
#数据库连接配置
db.driverClassName=com.mysql.jdbc.Driver
db.url=VjG9ty54tspjXih4i7GttGhMgOjH9n9fK+PmEKzqTNldvpAhYfSUuRBTf3b++nhyUZERvK3jb0VqFpnhJF0Whf1k7QSvjxxY1FaNlCT+Vz5cwk3kNBUfUHZ5EcLPNLOl
db.user=0q87vZtbVbk=
db.password=XfSWPx0Kqvg=
db.initialSize=2
db.minIdle=2
db.maxActive=10
db.maxWait=6000
#邮件服务器设置
mail.smtp.host=smtp.qiye.163.com
mail.smtp.port=465
mail.smtp.auth=true
mail.smtp.timeout=25000
mail.username=******@****.com
mail.password=*******
#Redis缓存配置
redis.minIdle=5
redis.maxIdle=100
redis.maxTotal=300
redis.maxWaitMillis=3000
redis.testOnBorrow=true
redis.host=127.0.0.1
redis.port=6379
redis.password=yxt123
redis.database=1
配置文件到这里都差不多了 文件内注解都有应该都能看懂至于框架的详细功能和实现方式就下次有时间在写!
最后如果还有不懂的地方 项目地址给奉献上了 源代码地址