Spring-config.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:aop="http://www.springframework.org/schema/aop"       xmlns:tx="http://www.springframework.org/schema/tx"       xmlns:p="http://www.springframework.org/schema/p"       xmlns:context="http://www.springframework.org/schema/context"       xmlns:cache="http://www.springframework.org/schema/cache"       xmlns:mvc="http://www.springframework.org/schema/mvc"       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd      http://www.springframework.org/schema/cache     http://www.springframework.org/schema/cache/spring-cache.xsd        http://www.springframework.org/schema/tx         http://www.springframework.org/schema/tx/spring-tx.xsd ">    <!-- 配置数据源 -->    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">        <property name="driverClass" value="com.mysql.jdbc.Driver"/>        <property name="jdbcUrl"                  value="jdbc:mysql://localhost:3306/pea"/>        <property name="user" value="root"/>        <property name="password" value="123456"/>        <property name="minPoolSize" value="5"/>        <property name="maxPoolSize" value="20"/>    </bean>    <!-- 配置SqlSessionFactoryBean -->    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">        <property name="dataSource" ref="dataSource"/>    </bean>     <bean id="UserMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">         <property name="mapperInterface" value="weixin.pea.pojo.UserMapper" />          <property name="sqlSessionFactory" ref="sqlSessionFactory" />   </bean>    <!-- 配置DataSourceTransactionManager(事务管理) -->    <bean id="transactionManager"          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">        <property name="dataSource" ref="dataSource"/>    </bean>     <!--验证器-->    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">        <!--注入hibernate的验证器-->        <property name="providerClass"  value="org.hibernate.validator.HibernateValidator"/>   </bean>   <!-- 配置multipart解析器 -->  <bean id="multipartResolver" class="org.springframework.web.multipart.support.StandardServletMultipartResolver" />    <!-- 使用声明式事务管理方式 -->    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> </beans>复制代码

SpringMVC-servlet.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:jdbc="http://www.springframework.org/schema/jdbc"  xmlns:jee="http://www.springframework.org/schema/jee"    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/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/tx    http://www.springframework.org/schema/tx/spring-tx.xsd  http://www.springframework.org/schema/aop   http://www.springframework.org/schema/aop/spring-aop.xsd">     <!-- 配置视图解析器 -->     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">         <!-- 使用前缀和后缀 -->         <property name="prefix" value=""></property>         <property name="suffix" value=".jsp"></property>     </bean>     <!-- 使用注解驱动,不用注解驱动,component-scan则无效,bean也无法装配 -->     <!-- 使用注解驱动,会自动注册处理器适配器 -->     <mvc:annotation-driven></mvc:annotation-driven>    <!-- 设置使用注解的类所在的包 -->   <context:component-scan base-package="weixin.pea.*" >   </context:component-scan>     <!-- 配置注解的处理器映射器和处理器适配器 -->      <!-- 访问静态资源文件处理器,<mvc:default-servlet-handler/>,没配置这个就访问不了图片,css,js等静态资源-->  <mvc:default-servlet-handler/><!--         配置拦截器   <mvc:interceptors>    <mvc:interceptor> <mvc:mapping path="*.do" />    <bean class=""></bean>   </mvc:interceptor>    </mvc:interceptors>     --> </beans>复制代码

web.xml

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/javaee"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">      <display-name>weixin.pea</display-name> <context-param>       <param-name>contextConfigLocation</param-name>      <param-value>classpath:spring-config.xml</param-value>  </context-param>  <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>   <filter>        <filter-name>encodingFilter</filter-name>        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>        <async-supported>true</async-supported>        <init-param>        <param-name>encoding</param-name>        <param-value>UTF-8</param-value>        </init-param>    </filter>    <filter-mapping>       <filter-name>encodingFilter</filter-name>       <url-pattern>/*</url-pattern>    </filter-mapping> <servlet>     <servlet-name>SpringMVC</servlet-name>      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>        <init-param>          <param-name>contextConfigLocation</param-name>          <param-value>classpath:SpringMVC-servlet.xml</param-value>      </init-param>     <load-on-startup>1</load-on-startup>        <multipart-config>            <location>/Users/pengchunkao/eclipse-workspace/pea/src/main/webapp/image/</location>            <max-file-size>2097152600</max-file-size>           <max-request-size>4194304600</max-request-size>     </multipart-config>   </servlet>    <servlet-mapping>         <servlet-name>SpringMVC</servlet-name>    <!--        一般有以下写法:        *.do    拦截固定格式的请求        /       rest风格的写法:拦截所有资源,需要针对静态资源做单独处理        /*      错误写法:会在处理完请求后拦截jsp导致404错误     -->            <url-pattern>/</url-pattern>    </servlet-mapping>    <!-- 添加这个servlet --></web-app>复制代码

转载于:https://juejin.im/post/5cde6ae751882525b40cc890

Spring+SpringMVC+Mybatics配置文件解析相关推荐

  1. Spring运行期间配置文件解析返回

    在Spring中有一个接口,可以做到在代码运行期间获取到配置文件的属性,也就是可以做到自己定义并解析@Value("${}")注解的功能. public interface Emb ...

  2. 菜鸟学习Spring——SpringMVC注解版解析不同格式的JSON串

    一.概述 不同格式的JSON串传到后台来实现功能这个是我们经常要做的一件事,本篇博客就给大家介绍四种不同的JSON串传到后台后台如何用@RequestBody解析这些不同格式的JSON串的. 二.代码 ...

  3. 系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常...

    现象:spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException; lineNumb ...

  4. Spring+SpringMVC +MyBatis整合配置文件案例66666

    Spring+SpringMVC +MyBatis整合配置文件案例 标签: springspringmvcmybatismvcjava 2017-04-13 19:12 228人阅读 评论(1) 收藏 ...

  5. Spring Boot(17)配置文件解析

    Spring Boot(17)配置文件解析 前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用"习惯优于配置"(项目中存在大量的配置,此外还内置了一个 ...

  6. Spring Boot干货系列:(二)配置文件解析

    前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用"习惯优于配置"(项目中存在大量的配置,此外还内置了一个习惯性的配置,让你无需手动进行配置)的理念让 ...

  7. spring+springMVC+配置文件propertites

    2019独角兽企业重金招聘Python工程师标准>>> web.xml: <listener><listener-class>org.springframew ...

  8. Spring+SpringMVC+Mybatis整合

    一.简单测试工程搭建 1.Mybatis所需要的的jar包(包含数据库驱动包和相关的日志包).SpringMVC和Spring的jar包 2.然后构建一个基本的工程,这里我们使用mapper代理的方式 ...

  9. Spring+SpringMVC+MyBatis深入学习及搭建(十)——MyBatis逆向工程

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6973266.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(九)--My ...

最新文章

  1. 狗年拜年php源码,2018狗年拜年词大全!再也不担心拜年没祝词啦~祝您新年快乐!...
  2. 演练:开发和使用自定义服务器控件
  3. Linux小工具(3)之/proc目录详细介绍(上)
  4. 单片机光敏电阻控制蜂鸣器_走进单片机|第七期:湿度检测
  5. 设计|从活泼的C端产品到严肃B端产品设计,我是如何自如切换的
  6. Nacos源码服务发现
  7. 程序员过关斩将--互联网人必备知识cookie和session认证
  8. 进程间的通讯(IPC)方式
  9. html怎么在字体中加波浪线,CSS3实现文字波浪线效果
  10. VC----SDK下对窗口非客户区的操作
  11. round()四舍五入方法的简单使用
  12. 自适应自旋锁--吞吐量和延迟以及管理开销的折中
  13. 万字长文带你从头构建文本分类器
  14. SaltStack ----(五)Jinja模板的使用
  15. blog11 Sent2Vec和Doc2Vec预训练模型
  16. 快递面单打印报错:“print selected is not valid” 解决方案
  17. ym——Android从零开始(3)(常用控件+下拉框视图)(新)
  18. 原生html单页应用,web单页应用
  19. 电梯广告框尺寸批发供应|电梯相框广告规格
  20. win7屏幕亮度怎么调_win7屏幕亮度调整方法

热门文章

  1. centos7数据库mysql+mariadb
  2. 写给MongoDB开发者的50条建议Tip25
  3. centos 网卡配置(入门级)
  4. javaweb学习总结二十五(response对象的用法一)
  5. 精通Server Core系列之一 ---Server Core简介
  6. 请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如Page 或UserControl)是正确的。...
  7. 列出所有已安装的perl模块
  8. Java虚拟机常见面试题
  9. Redis 在CentOS 6上的 安装和部署以及redis的主从复制sentinel实现HA
  10. [转]解读ASP.NET 5 MVC6系列(7):依赖注入