简单SSM框架实现增删改查

本文档介绍了如何使用SSM(Spring、SpringMVC、Mybatis)框架实现简单的增删改查功能。首先创建了一个maven的web项目,设置了相应的目录结构,并在pom.xml中添加了必要的依赖。接着,通过Mybatis的逆向工程生成了DAO层的相关文件,包括接口、映射文件、POJO类和Example类。然后配置了applicationContext.xml、springmvc.xml、db.properties和mybatis.xml等核心配置文件。在service层定义并实现了接口,在controller层编写了对应的控制逻辑。最后,配置了web.xml以整合Spring和SpringMVC。经过一系列的测试,成功实现了预期的增删改查功能。
摘要由CSDN通过智能技术生成

1.创建maven的web项目,创建如下的简单目录结构:
在这里插入图片描述
2.在pom文件中添加相关jar包依赖以及配置tomcat插件:
在这里插入图片描述

<build>
		<plugins>
			<!-- tomcat插件 -->
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<!-- 端口号 -->
					<port>8082</port>
					<!-- /表示访问路径 省略项目名 -->
					<path>/</path>
					<!-- 设置编码方式 -->
					<uriEncoding>utf-8</uriEncoding>
				</configuration>
			</plugin>
		</plugins>
	</build>

3.在/com-sb-ssm/src/main/resources目录下创建如下文件:
在这里插入图片描述
使用mybatis的逆向工程生成dao层的接口文件、映射文件、pojo类、pojoexample类:
在这里插入图片描述
4.配置文件的设置:
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"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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.3.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
	<!-- 关联数据属性文件,注意加上classpath -->
	<context:property-placeholder location="classpath:db.properties"/>
	<!-- 开启扫描 -->
	<context:component-scan base-package="com.sb.service.impl"/>
	<!-- 配置数据源 -->
	<bean class="com.mchange.v2.c3p0.ComboPooledDataSource" 
	id="dataSource" >
		<property name="driverClass" value="${driverName}"></property>
		<property name="jdbcUrl" value="${url}"></property>
		<property name="user" value="${names}"><
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值