记录地址

jdk设置及文件包miss

实例下载地址

创建SSM整合项目

一.使用Eclipse中的maven插件创建web项目

  1:

    

   2:

    

    3:

    

    4:

    

    5:maven web项目创建成功。(去掉index.jsp文件重新创建jsp文件,报错消失)

    

    6.

  7.

  8.Eclipse创建一个动态web项目,将其中的web.xml配置文件拷贝到maven项目中,注意修改项目名称。

二、添加xml配置

  1.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" id="WebApp_ID" version="3.1">
<display-name>mybatis-spring02</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <!-- web容器启动时根据contextConfigLocation配置的路径读取Spring的配置文件,然后启动Spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 配置Springmvc所有的请求都要通过DispatcherServlet -->
<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>
</servlet> <servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <!-- 编码utf-8 -->
<filter>
<filter-name>SpringEncodingFilter</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>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

 2.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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
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.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <!-- 启用Controller注解支持 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 配置一个简单的静态资源映射规则 -->
<mvc:resources location="static/" mapping="/static/**"></mvc:resources>
<!-- 扫描Controller包下面的类 -->
<context:component-scan base-package="com.watermelon.*.controller"></context:component-scan>
<!-- InternalResourceViewResolver将视图名映射为URL文件 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>

3.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>
<setting name="logImpl" value="LOG4J"/>
<setting name="cacheEnabled" value="true"/>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<setting name="aggressiveLazyLoading" value="false"/>
</settings> </configuration>

4.log4j.properties

### Global logging configuration
log4j.rootLogger=ERROR, stdout ### Uncomment for MyBatis logging
log4j.logger.com.watermelon.web.mapper=TRACE ### Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

5.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://www/springframework.org/schema/context http://www/springframework.org/schema/context/spring-context.xsd
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
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.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!--spring -->
<context:component-scan base-package="com.watermelon.web.service.impl"/> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="addToConfig" value="true"/>
<property name="basePackage" value="com.watermelon.web.mapper"/>
</bean> <!-- spring自动扫描 包下面的带注解的类,并注册到Sping的bean容器中 service.impl
<context:component-scan base-package="com.watermelon.web.service.impl"></context:component-scan>-->
<!-- mybatis-spring:scan 会扫描com.watermelon.dao包下面的所有接口当作Spring的bean配置
<mybatis-spring:scan base-package="com.watermelon.web.mapper"/>--> <bean id="dataSource" class="org.apache.ibatis.datasource.pooled.PooledDataSource">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/simple"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations">
<array>
<value>classpath:com/watermelon/web/mapper/*.xml</value>
</array>
</property>
<property name="typeAliasesPackage" value="com.watermelon.web.model"/>
</bean>   <!-- Spring aop事务 -->
<aop:aspectj-autoproxy/> <aop:config>
<aop:pointcut id="appService" expression="execution(* com.watermelon.*.service..*Service*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="appService"/>
</aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="select*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean> </beans>

项目结构:

    

eclipse maven创建web项目的更多相关文章

  1. Eclipse maven创建web项目报错Could not resolve archetype

    1.下载http://repo1.maven.org/maven2/archetype-catalog.xml 通过eclipse下载和网页下载我这里都比较慢,最后用的迅雷下载 2.将本地xml文件配 ...

  2. (转)Maven学习总结(七)——eclipse中使用Maven创建Web项目

    孤傲苍狼只为成功找方法,不为失败找借口! Maven学习总结(七)——eclipse中使用Maven创建Web项目 一.创建Web项目 1.1 选择建立Maven Project 选择File -&g ...

  3. Maven学习总结(7)——eclipse中使用Maven创建Web项目

    Maven学习总结(七)--eclipse中使用Maven创建Web项目 一.创建Web项目 1.1 选择建立Maven Project 选择File -> New ->Project,如 ...

  4. Eclipse+Maven创建webapp项目<一>(转)

    还在为jar下载而烦恼吗?还在为jar依赖关系而烦恼吗?还在为jar冲突而烦恼吗?强大的maven项目管理工具来拯救你们呢?自动下载jar,自动下载jar依赖包.你什么都不用做,只需要在中央仓库中co ...

  5. Eclipse+Maven创建webapp项目

    Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new-->other,如下图找到maven project 2.选择maven project,显 ...

  6. Eclipse+Maven创建webapp项目<一>

    Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new——>other,如下图找到maven project 2.选择maven project,显 ...

  7. Eclipse+Maven创建webapp项目<一><二><三>

    转-http://www.cnblogs.com/candle806/p/3439469.html Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new ...

  8. Eclipse+Maven创建webapp项目<一> (转)

    Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new——>other,如下图找到maven project 2.选择maven project,显 ...

  9. maven 创建web项目的标准目录结构

      maven 创建web项目的标准目录结构 CreateTime--2018年4月18日21:05:37 Author:Marydon 1.标准目录介绍(开发目录) 2.在eclipse下,目录展示 ...

随机推荐

  1. pcb中几个层的解释

    阻焊层(Solder Mask):又称为绿油层,是PCB的非布线层,用于制成丝网漏印板,将不需要焊接的地方涂一层阻焊物质,防止焊接PCB时焊锡在高温下的流动性.在阻焊层上预留的焊盘大小,要比实际焊盘大 ...

  2. POJ 2479 两段连续最大和

    题目大意: 在一组数中,找到连续的两段 , 是这两段相加和达到最大 这里利用dp[2][N]的数组保存所有的状态 dp[0][i]表示取到第i个数时只取了一段的最大和,第i个数是一定要被取到的 dp[ ...

  3. noip模拟赛 斐波那契

    分析:暴力分有90,真良心啊. a,b这么大,连图都建不出来,肯定是有一个规律.把每个点的父节点写出来:0 1 1 12 123 12345 12345678,可以发现每一个循环的长度刚好是斐波那契数 ...

  4. 常用生产环境的PHP安装参数

    ./configure --prefix=/usr/local/php5. --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/b ...

  5. [NOIP2007] 普及组

    奖学金 模拟 开个struct排序即可 c++吼啊 /*by SilverN*/ #include<algorithm> #include<iostream> #include ...

  6. TOMCAT加载两次war包(重复加载)

    一.问题描述 项目中通过配置Context节点docBase,使docBase指向项目的绝对路径,可以直接通过IP加端口访问,今日发现意外bug,项目中某个功能奇数次执行成功,偶数次执行失败.二.问题 ...

  7. [bzoj1430]小猴打架_prufer序列

    小猴打架 bzoj-1430 题目大意:题目链接. 注释:略. 想法: 我们发现打架的情况就是一棵树. 我们只需要把确定树的形态然后乘以$(n-1)!$表示生成这棵树时边的顺序. 一共$n$个节点我们 ...

  8. Ubuntu 16.04安装qt5-default报错:qt5-default : 依赖: qtbase5-dev E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。(此类问题终极解决方法)

    切记:没事不要进行sudo apt-get upgrade 错误: qt5-default : 依赖: qtbase5-dev E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间 ...

  9. 打造Spring Cloud构建微服务架构的最全资料

    访问: https://git.oschina.net/didispace/SpringCloud-Learning http://blog.didispace.com/categories/Spri ...

  10. 【c++】C语言中volatile关键字的作用

    因为访问寄存器要比访问内存单元快的多,所以编译器一般都会作减少存取内存的优化,但有可能会读脏数据.当要求使用volatile声明变量值的时候,系统总是重新从它所在的内存读取数据,即使它前面的指令刚刚从 ...