SSM+shiro,所有配置文件,详细注释版,自用
spring配置文件applicationContext.xml,放在resources下
- <?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"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.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">
- <!--Spring配置文件的核心点( 1、数据源 2、与mybatis的整合 3、事务控制 )-->
- <!--业务逻辑组件扫描进来-->
- <context:component-scan base-package="club.iashe">
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- </context:component-scan>
- <!--==================================================================================================================-->
- <!--数据源的配置-->
- <!--引入外部的配置文件-->
- <context:property-placeholder ignore-unresolvable="true" location="classpath:dbconfig.properties"/>
- <!-- 数据库连接池c3p0配置数据源 -->
- <bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
- <property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
- <property name="driverClass" value="${jdbc.driverClass}"/>
- <property name="user" value="${jdbc.user}"/>
- <property name="password" value="${jdbc.password}"/>
- </bean>
- <!--==================================================================================================================-->
- <!--配置和mybatis整合-->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <!--指定mybatis全局配置文件的位置-->
- <property name="configLocation" value="classpath:mybatis-config.xml"/>
- <!--指定数据源-->
- <property name="dataSource" ref="pooledDataSource"/>
- <!--指定mybatis映射文件的位置-->
- <property name="mapperLocations" value="classpath:mapper/*Mapper.xml"/>
- </bean>
- <!--配置扫描器,将mybatis接口的实现,即DAO接口所在包名,加入到IOC容器中-->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <!--扫描所有dao接口的实现,加入到IOC容器中-->
- <property name="basePackage" value="club.iashe.dao"/>
- </bean>
- <!--配置一个可以执行批量的sqlSession-->
- <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" >
- <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
- <!--<constructor-arg name="executorType" value="BATCH" />-->
- </bean>
- <!--==================================================================================================================-->
- <!-- 事务控制的配置,spring声明式事务 -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <!--控制住数据源-->
- <property name="dataSource" ref="pooledDataSource"/>
- </bean>
- <!--开启基于注解的事务/使用xml配置形式的事务(一般比较重要的都使用xml形式)-->
- <aop:config>
- <!--切入点表达式-->
- <aop:pointcut expression="execution(* club.iashe.service..*(..))" id="txPoint"/>
- <!--<aop:pointcut id="txPoint" expression="execution(* cn.crud.service..*(..))"/>-->
- <!--配置事务增强-->
- <aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/>
- </aop:config>
- <!--配置事务增强,也就是事务如何切入-->
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <!--代表这个切入点的所有方法都是事务方法-->
- <tx:method name="*"/>
- <!--以get开始的所有方法,进行调优-->
- <tx:method name="get*" read-only="true"/>
- </tx:attributes>
- </tx:advice>
- <!--==================================================================================================================-->
- </beans>
springMVC配置文件,dispatcherServlet-servlet.xml,放在WEB-INF下
- <?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.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd">
- <!--两个标准配置-->
- <!--将springMVC不能处理的请求交给tomcat-->
- <mvc:default-servlet-handler />
- <!--能支持springMVC一些更高级的功能,注释替代XML配置,jrs303校验,快捷的ajax,映射动态请求-->
- <!--<mvc:annotation-driven />-->
- <!-- 使用fastjson替换springMVC默认的Jackson -->
- <mvc:annotation-driven>
- <mvc:message-converters register-defaults="true">
- <!-- 配置fastjson支持 -->
- <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
- <property name="defaultCharset" value="UTF-8" />
- <property name="supportedMediaTypes">
- <list>
- <value>text/html;charset=UTF-8</value>
- <value>application/json</value>
- </list>
- </property>
- </bean>
- </mvc:message-converters>
- </mvc:annotation-driven>
- <!--
- springMVC的配置文件,包含网站跳转逻辑的控制、配置
- 注释改掉默认扫描所有use-default-filters,设为false
- -->
- <context:component-scan base-package="club.iashe" use-default-filters="false">
- <!--只扫描控制器-->
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
- </context:component-scan>
- <!-- 配置视图解析器,方便页面返回信息 -->
- <!-- 配置 HTML 视图解析器 -->
- <!-- html视图解析器,必须先配置freemarkerConfig,html没有prefix属性 -->
- <!--<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
- <property name="resourceLoader">
- <value>/html/</value>
- </property>
- </bean>
- <bean id="htmlViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
- <property name="suffix" value="html" />
- <property name="order" value="0"/>
- <property name="contentType" value="text/html;charset=UTF-8" />
- </bean>-->
- <!-- 配置 jsp 视图解析器 -->
- <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <!--<property name="prefix" value="WEB-INF/views/" /> <!–前缀–>-->
- <property name="prefix" value="WEB-INF/admin/views/" /> <!--前缀-->
- <property name="suffix" value=".jsp" /> <!--后缀-->
- </bean>
- </beans>
mybatis配置文件,mybatis-config.xml,resources下
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
- <configuration>
- <settings>
- <!-- Globally enables or disables any caches configured in any mapper under this configuration -->
- <setting name="cacheEnabled" value="false"/>
- <!-- Sets the number of seconds the driver will wait for a response from the database -->
- <setting name="defaultStatementTimeout" value="5"/>
- <!-- Enables automatic mapping from classic database column names A_COLUMN to camel case classic Java property names aColumn -->
- <!-- 数据库下划线转为驼峰 -->
- <setting name="mapUnderscoreToCamelCase" value="true"/>
- <!-- Allows JDBC support for generated keys. A compatible driver is required.
- This setting forces generated keys to be used if set to true,
- as some drivers deny compatibility but still work -->
- <setting name="useGeneratedKeys" value="true"/>
- </settings>
- <!-- Continue editing here -->
- <!--起别名-->
- <typeAliases>
- <package name="club.iashe.pojo" />
- </typeAliases>
- <!--配置PageHelper插件-->
- <plugins>
- <!-- com.github.pagehelper为PageHelper类所在包名 -->
- <plugin interceptor="com.github.pagehelper.PageInterceptor">
- <!-- 使用下面的方式配置参数,后面会有所有的参数介绍 -->
- <!--<property name="param1" value="value1"/>-->
- <!-- 分页参数合理化 -->
- <property name="reasonable" value="true" />
- </plugin>
- </plugins>
- </configuration>
mybatis-generator-config配置文件
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE generatorConfiguration
- PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
- "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
- <generatorConfiguration>
- <!-- 引入配置文件 -->
- <properties resource="dbconfig.properties" />
- <context id="DB2Tables" targetRuntime="MyBatis3">
- <!--配置生成的增删改查方法不要注释-->
- <commentGenerator>
- <property name="suppressAllComments" value="true" />
- </commentGenerator>
- <!--配置数据库链接信息-->
- <jdbcConnection driverClass="${jdbc.driverClass}"
- connectionURL="${jdbc.jdbcUrl}"
- userId="${jdbc.user}"
- password="${jdbc.password}">
- </jdbcConnection>
- <javaTypeResolver >
- <property name="forceBigDecimals" value="false" />
- </javaTypeResolver>
- <!--java模型生成,指定JavaBean生成的位置-->
- <javaModelGenerator targetPackage="club.iashe.pojo"
- targetProject=".\src\main\java">
- <property name="enableSubPackages" value="true" />
- <property name="trimStrings" value="true" />
- </javaModelGenerator>
- <!--指定sql映射文件的位置-->
- <sqlMapGenerator targetPackage="mapper"
- targetProject=".\src\main\resources">
- <property name="enableSubPackages" value="true" />
- </sqlMapGenerator>
- <!--指定DAO接口生成的位置-->
- <javaClientGenerator type="XMLMAPPER"
- targetPackage="club.iashe.dao"
- targetProject=".\src\main\java">
- <property name="enableSubPackages" value="true" />
- </javaClientGenerator>
- <!--指定每个表的生成策略-->
- <!--<table tableName="resident_tag" domainObjectName="ResidentTag" />-->
- <table tableName="resident_info" domainObjectName="ResidentInfo" />
- </context>
- </generatorConfiguration>
数据库配置文件dbconfig.properties
- jdbc.jdbcUrl=jdbc:mysql://localhost:3306/community?serverTimezone=UTC&zeroDateTimeBehavior=round
- jdbc.driverClass=com.mysql.cj.jdbc.Driver
- jdbc.user=root
- jdbc.password=
最后,web.xml的配置
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
- version="3.1">
- <!-- web.xml文件的配置 -->
- <!-- 1.启动spring容器 -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <!-- spring配置文件路径 -->
- <param-value>classpath:applicationContext.xml</param-value>
- </context-param>
- <!-- spring监听器 -->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!-- 2、springMVC的前端控制器,拦截所有请求 -->
- <servlet>
- <!-- 配置springMVC的dispatcherServlet分发请求,实际上它是一个前端控制器 -->
- <servlet-name>dispatcherServlet</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatcherServlet</servlet-name>
- <!--拦截所有页面请求-->
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <!--3、字符编码过滤器,第一位的过滤器-->
- <filter>
- <filter-name>CharacterEncodingFilter</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>
- <init-param>
- <param-name>forceRequestEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>forceResponseEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CharacterEncodingFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!-- 4、使用rest风格的URI,将页面普通的post请求转为指定的delete或者put请求 -->
- <filter>
- <!-- hiddenHttpMethodFilter 可以把把post请求转船成 put delete -->
- <filter-name>HiddenHttpMethodFilter</filter-name>
- <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>HiddenHttpMethodFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- </web-app>
SSM+shiro,所有配置文件,详细注释版,自用的更多相关文章
- 经典剪枝算法的例题——Sticks详细注释版
这题听说是道十分经典的剪枝算的题目,不要问我剪枝是什么,我也不知道,反正我只知道用到了深度搜索 我参考了好多资料才悟懂,然后我发现网上的那些大神原理讲的很明白,但代码没多少注释,看的很懵X,于是我抄起 ...
- SSM+shiro及相关插件的整合maven所有依赖,详细注释版,自用,持续更新
整合了SSM+shiro框架,slf4j+logback日志,及一些好用的插件PageHelper,mybatis-generator,Lombok,fastjson等等 <?xml versi ...
- 一套强大的vim配置文件+详细注释
phpchina折腾王独家配置,灰常牛叉的一套vim配置,另附有详细注释,自己折腾vim的时候可以参照其中的大部分设置进行一些个性化定制."是否兼容VI,compatible为兼容,noco ...
- SSM项目spring配置文件详细步骤(分门别类、灵巧记忆)
spring-dao.xml文件 1.配置外部db.property文件: <context:property-placeholder location="classpath:jdbc ...
- DRF 简单使用(详细注释版)
1.djangorestframework使用 下载安装 pip install djangorestframework ## djangorestframework pip install djan ...
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)【转】
使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)(转)
使用 SSM ( Spring . SpringMVC 和 Mybatis )已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没 ...
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)
使用 SSM ( Spring . SpringMVC 和 Mybatis )已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没 ...
- SSM三大框架整合详细教程
使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...
随机推荐
- P1705 爱与愁过火(背包)
本来是个搜索题,但是自觉的成了背包! 多重用正序,01用逆序. 抽象出来一下,一个物体的体积为ai, 每次装入背包需要bi(在题目中为菜数量)分钟(这个题目只是bi为 1 而已)问在r分钟内,装比n大 ...
- KazaQ's Socks (找规律)
#include<iostream> using namespace std; #define ll long long ll n, m; ll t; int main(){ while ...
- Ubuntu 14.04 安装配置备忘录
完全在 Linux 下工作,大概有3年时间了. 之前都是用 Windows, 而把 Linux 装在虚拟机里,现在反过来,把 Windows 装在了虚拟机里,只是因为偶尔还要用网银的缘故. 以我这几年 ...
- 接口测试,获取登录后的cookies
参见: http://www.cnblogs.com/testwang/p/6023394.html
- Luogu P3703 [SDOI2017]树点涂色
比较有趣的综合树上问题,刷LCT题单时做的但是发现后面LCT只是起了辅助作用233 首先我们分析每一个操作,\(1\)的定义就让我们联想到了access,我们回忆一下LCT的性质: LCT中每一个sp ...
- 图解SSH原理及两种登录方法
SSH(Secure Shell)是一套协议标准,可以用来实现两台机器之间的安全登录以及安全的数据传送,其保证数据安全的原理是非对称加密. 传统的对称加密使用的是一套秘钥,数据的加密以及解密用的都是这 ...
- 微信小程序开发平台新功能「云开发」快速上手体验
微信小程序开发平台刚刚开放了一个全新的功能:云开发. 简单地说就是将开发人员搭建微信小程序后端的成本再次降低,此文刚好在此产品公测时,来快速上手看看都有哪些方便开发者的功能更新. 微信小程序一直保持一 ...
- struts2之配置文件struts.xml详解
struts配置文件 struts.xml配置参数详解 struts.xml中很大一部分配置默认配置就好了 但是有些还是需要做了解 以便于理解 和修改 <?xml version=" ...
- VMware威睿
VMware总部位于美国加州帕洛阿尔托 [1] ,是全球云基础架构和移动商务解决方案厂商,提供基于VMware的解决方案, 企业通过数据中心改造和公有云整合业务,借助企业安全转型维系客户信任 [2- ...
- 【学习总结】GirlsInAI ML-diary day-6-String字符串
[学习总结]GirlsInAI ML-diary 总 原博github链接-day6 认识字符串 字符串的性质 字符串的玩法 1-字符串就是字符的序列 序列,代表字符串是有顺序的!这里很重要. 比如我 ...