jar包依赖:网址search.maven.org

1.spring :spring-core            2. myhabits:myhabits

3.整合spring和myhabits:myhabits-spring

4.连接数据库:mysql:mysql-connector-java

5.测试包:junit       添加作用域<scope>test</scope>

6.引入数据源的jar包    例:druid、jdbc、c3p0

spring.xml//自动扫描,自动注入<context:component-scan base-package="mygd.service"

//弹出引入注解的框  Alt+Shift+s

7.org.aspectj   weaver    jar包

8.springmvc:spring-webmvc

//自动扫描controller包下的所有类,使其认为spring mvc的控制器

<context:component-scan base-package="sy.controller"/>

//可以配置Jackson避免IE执行AJAX时,返回json出现下载文件   导入包  jackson-mapper-asi

class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"

<ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->

//启动spring MVC的注解功能,完成请求和注解POJO的映射

9.文件上传包    commons-fileupload

10.请求包     javax.servlet

11.log4j

12.fastjson

----------------------------------------------------------------------------------------------------------------------------------------------

//项目启动  配置web-xml

<context-param>
<param-name>contextConfigLocation</param-name>           contextConfigLocation    上下文
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<filter></filter>   过滤器   可以设置字符编码

<filter-mapping>   </filter-mapping>    映射

<listener>         //监听器
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

1.配置前端控制器//<servlet>为重点           配置前端控制器DispatcherServlet

<servlet>
<servlet-name>mybatis</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

//复制spring-web-4.1.2.RELEASE-sources.jar包下的DispatcherServlet.class
<init-param>    //初始参数  源码里面

<!--contextConfigLocation配置springmvc加载的配置文件(配置处理器映射器,适配器等等)    -->
<param-name>contextConfigLocation</param-name>
<param-value>classpath:mybatis-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mybatis</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

在上文的classpath下,也就是mybatis-servlet.xml中配置处理器映射器,处理器适配器,配置视图解析器

mybatis-servlet.xml开头部分配置springmvc的头

<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: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/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

</beans>

2.配置处理器映射器

3.配置处理器适配器

继承HandlerAdapter

4.配置视图解析器

<property name="viewResolvers">
<list>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />     //前缀
<property name="suffix" value=".jsp" />                //后缀
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="marshaller" ref="castorMarshaller" />
</bean>
</list>
</property>

---------------------------------------------------------------------------------------------------------------------------------------

log4j配置文件

开发阶段建议开启DEBUG模式  stdout

log4j.rootLogger=INFO,Console,File
#log4j.logger.java.sql.PreparedStatement=DEBUG,stdout          //开发阶段的日志
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n

log4j.appender.File = org.apache.log4j.RollingFileAppender
log4j.appender.File.File = logs/ssm.log
log4j.appender.File.MaxFileSize = 10MB
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

spring+springmvc+maven+mybatis整合的更多相关文章

  1. Spring SpringMVC和Mybatis整合

    1.引入所要的jar包 2.创建Mybatis的sqlMapConfig.xml配置文件,该文件中可以配置mybaits的相关参数,数据源不在这里配置. <?xml version=" ...

  2. Eclipse+Spring+SpringMVC+Maven+Mybatis+MySQL+Tomcat项目搭建

    ---恢复内容开始--- 1. 建表语句及插入数据 CREATE TABLE `book_user` ( user_id INT(11) NOT NULL AUTO_INCREMENT, user_n ...

  3. 转载 Spring、Spring MVC、MyBatis整合文件配置详解

    Spring.Spring MVC.MyBatis整合文件配置详解   使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用法最好还是看官方文档. ...

  4. SpringMVC与mybatis整合

    一.逆向工程生成基础信息 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generator ...

  5. Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境( ...

  6. eclipse下SpringMVC+Maven+Mybatis+MySQL项目搭建

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 接下来马上进入项目搭建 ...

  7. SpringMVC学习记录三——8 springmvc和mybatis整合

    8      springmvc和mybatis整合 8.1      需求 使用springmvc和mybatis完成商品列表查询. 8.2      整合思路 springmvc+mybaits的 ...

  8. spring+springmvc+maven+mongodb

    1.前言 最近项目开发使用到了spring+springmvc+maven+mongodb,项目中的框架是用springboot进项开发的,对于我们中级开发人员来说,有利有弊,好处呢是springbo ...

  9. SpringMvc基础知识(二) springmvc和mybatis整合

    1 springmvc和mybatis整合 1.1 需求 使用springmvc和mybatis完成商品列表查询. 1.2 整合思路 springmvc+mybaits的系统架构: 第一步:整合dao ...

随机推荐

  1. ASP.NET WebForm 的路由

    ASP.NET WebForm 的路由 偷会闲, 看看博客园, 有筒子写了篇: ASP.NET的路由 我翻了翻两前的一份邮件, 是我当时在项目之余的时间研究的,那时还没用MVC,所有项目都是 WebF ...

  2. c语言:将二进制数按位输出

    问题: 1.输入int 20,其二进制为10100,按位输出10100; 2.或者将1转化为“+”,0转化为“-”,输出就是” + - + - - “; int biTofh(int bi,int l ...

  3. javascript继承的写法

    原文链接:http://js8.in/698.html. 构造函数继承: 第一种方法是使用prototype属性: 这里也可以直接Child.prototype=new P();考虑到P构造函数的参数 ...

  4. jQuery Mobile (整合版)

    jQuery Mobile (整合版) 前言 为了方便大家看的方便,我这里将这几天的东西整合一下发出. 里面的例子请使用手机浏览器查看. 什么是jQuery Mobile? jquery mobile ...

  5. 遭遇ORA-01078,LRM-00109,ORA-27046 SPFILE文件损坏

    今天在启动数据库时遭遇到 $ sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Tue Jul 16 21:28:03 ...

  6. [每日一题] OCP1z0-047 :2013-07-15 drop column

    如下实验: gyj@OCM> Create table emp( 2    Empno     number(4)    not null, 3    First_name  varchar2( ...

  7. struts征程:1.初识struts2

    1.struts2在开发中所必须用到的jar包导入到项目的lib目录下 2.在web.xml中配置一个过滤器,代码格式如下 <filter> <filter-name>stru ...

  8. JavaScript利用闭包实现模块化

    利用闭包的强大威力,但从表面上看,它们似乎与回调无关.下面一起来研究其中最强大的一个:模块. function foo() { var something = "cool"; va ...

  9. [ios2]iphone编程中使用封装的NSLog来打印调试信息 【转】

    使用NSLog的一个风险是:它的运行会占用时间和设备资源. 简单而粗暴的解决方案是:在release前,将所有的NSLog注释掉.简单有效,但副作用是:下次你要调试时,又得将NSLog一个个取消注释. ...

  10. hdu1046

    #include<iostream> #include<cmath> using namespace std; int main() { int T,t=0,m,n; cin& ...