eclipse 搭建 SSM 开发环境

本文档详细介绍了如何在Eclipse中搭建SSM(Spring、SpringMVC、MyBatis)开发环境,从创建动态Web工程、导入jar包、数据库准备到配置各个层面,包括DAO、Service、Controller层的配置以及web.xml文件的设置。
摘要由CSDN通过智能技术生成

目录

 

一、搭建分析

1)DAO 层

2)Service 层

3)Controller 层

4)web.xml 文件

二.开始搭建

1)创建动态 web 工程,并且进行项目分包

2)导入 jar 包

3)在数据库中添加数据

4)通过逆向工程生成对应的文件

5)添加配置文件

6)applicationContext-dao.xml 文件

7)applicationContext-service.xml 文件

8)applicationContext-trans.xml 文件

9)db.properties 文件

10)springmvc.xml 文件

11)web.xml 文件,配置 SpringMVC 和 Spring 容器。


一、搭建分析

1)DAO 层

POJO 类,对应的映射文件 XxxMapper.xml 和 XxxMapper.java 接口类文件。

SqlMapConfig.xml : MyBatis 的核心配置文件。

beans-dao.xml 配置文件:主要是把 DAO 交给 Spring 管理。

数据源 dbcp / c3p0

会话工厂 sqlSessionFactory

扫描 mapper

2)Service 层

事务:beans-trans.xml 配置文件:将事务交给 Spring 管理。

beans-service.xml 配置文件:将 Service 交给 Spring 管理。

3)Controller 层

springmvc.xml 文件

注解扫描:@Controller、@RequestMapping

注解驱动:最新版本的处理器映射器和处理器适配器。

视图解析器:指定页面路径的前缀和后缀。

4)web.xml 文件

springMVC 前端控制器:DispatcherServlet

spring 的监听器

二.开始搭建

1)创建动态 web 工程,并且进行项目分包

2)导入 jar 包

jar 包整合下载:

https://download.csdn.net/download/weidong_y/10617848

3)在数据库中添加数据

user 表

items 表

4)通过逆向工程生成对应的文件

5)添加配置文件

6)applicationContext-dao.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	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/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd 
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/util 
		http://www.springframework.org/schema/util/spring-util.xsd">
	<!-- 加载配置文件 -->
	<context:property-pla
  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值