ssM框架简单配置文件
来源:互联网 发布:wow7.0优化 编辑:程序博客网 时间:2024/05/19 20:37
1.web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"> <display-name>大众点评</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <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> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <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/applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <include-prelude>/WEB-INF/jsp/system/common.jsp</include-prelude> </jsp-property-group> </jsp-config></web-app>2.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" 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.1.xsd"> <context:property-placeholder location="classpath:properties/*.properties"/> <import resource="applicationContext-*.xml"/></beans>3.applicationContext-dao.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" 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"> <!--数据库连接池--> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${driver}"/> <property name="jdbcUrl" value="${url}"/> <property name="user" value="${username}"/> <property name="password" value="${password}"/> <!--c3p0连接池私有属性--> <property name="maxPoolSize" value="30"/> <property name="minPoolSize" value="10"/> <!--关闭连接后不自动提交--> <property name="autoCommitOnClose" value="false"/> <!--获取链接超时时间--> <property name="checkoutTimeout" value="1000"/> <!--当获取连接失败重试次数--> <property name="acquireRetryAttempts" value="5"/> </bean> <!--配置sqlSessionFactory对象--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!--注入数据库连接池--> <property name="dataSource" ref="dataSource"/> <!--配置mybatis全局配置文件:mybatis-config.xml--> <property name="configLocation" value="classpath:mybatis-config.xml"/> <!--扫描entity使用别名--> <property name="typeAliasesPackage" value="org.imooc.bean"/> <!--扫描sql配置文件:mapper需要的xml文件--> <property name="mapperLocations" value="classpath:mapper/*.xml"/> </bean> <!--配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--注入sqlSessionFactory--> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> <!--给出需要扫描的Dao接口--> <property name="basePackage" value="org.imooc.dao"/> </bean> <!--自动扫描包名--> <context:component-scan base-package="org.imooc.dao"/></beans>4.applicationContext-service.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: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/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"> <!--扫描service包下所有类型--> <context:component-scan base-package="org.imooc.service"/> <!--配置事物管理器--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!--注入数据库连接池--> <property name="dataSource" ref="dataSource"/> </bean> <!--配置基于注解的声明式事务 默认使用注解来管理事务行为--> <tx:annotation-driven transaction-manager="transactionManager"/></beans>5.applicationContext-web.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" xmlns:mvn="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/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 http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <!--开启注解--> <mvc:annotation-driven/> <!--允许对静态资源文件访问--> <mvc:default-servlet-handler/> <!--配置视图解析器--> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp"></property> <property name="suffix" value=".jsp"/> </bean> <!--配置文件上传解析器--> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!--指定所上传文件总大小不超过20M,注意maxUploadSize属性的限制不是针对单个文件--> <property name="maxUploadSize" value="20000000"/> <property name="defaultEncoding" value="utf-8"/> </bean> <!--自动扫描的包名--> <context:component-scan base-package="org.imooc.controller"/></beans>6.mybatis-config.xml
<?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> <!--使用jdbc的getGeneratedKeys,获取自增主键值--> <setting name="useGeneratedKeys" value="true"/> <!--使用列别名替换列名,默认true--> <setting name="useColumnLabel" value="true"/> <!--开启驼峰命名转换--> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings></configuration>
阅读全文
0 0
- ssM框架简单配置文件
- SSM框架的配置文件
- SSM框架配置文件整理
- ssm框架配置文件
- SSM框架整合 配置文件
- SSM框架配置文件上传
- ssm框架中的配置文件
- 一个简单的ssm框架maven项目的相关配置文件
- SSM:简单SSM框架整合
- 整合ssm框架之配置文件
- ssm框架搭建的配置文件
- SSM框架整合配置文件整理
- ssm框架的搭建配置文件
- SSM框架简单配置
- SSM框架简单配置
- ssm框架简单整合
- SSM框架简单整合
- 简单的SSM框架
- Zynq Emacps Linux Driver
- kivy textinput弹出输入框处理
- 设计模式学习:工厂模式
- springboot的三种启动方式
- 使用SfntTool制作字体剪辑工具1
- ssM框架简单配置文件
- 蓝桥杯 BASIC-26 基础练习 报时助手
- 机器学习算法实现解析——libFM之libFM的训练过程之SGD的方法
- B-1007
- webpack入门的配置遇到的问题
- java spring 皮毛
- 2018计算机考研政治总结3
- 6.5 JLL--实习日志
- [YTU]_2428(C语言习题 计算该日在本年中是第几天)