SSM实战项目,基于Spring+SpringMVC+mybatis实现的人事管理系统源码+数据库+使用说明

SSM实战项目:人事管理系统(蓝色版)

一、员工管理系统项目说明:

该项目主要是完成Spring+SpringMVC+mybatis的完整整合,功能实现比较单一,就是一个完成增删改查的小项目!

完整代码下载地址SSM实战项目,人事管理系统源码+数据库+使用说明

1、整个项目实现功能

1、管理员的登录,注册<br />2、员工的增删改查,批量删除<br />整个系统设计的目标人群是管理者,系统的主要功能是对员工进行各种信息的操作。<br />主要是完成对数据库的增删改查的功能。

2、开发环境

分类名称语种
操作系统windows10简体中文
数据库平台MySQL Server 8.0+
应用服务器apache-tomcat-8.5.71
java开发工具idea
框架mybatis+Spring+SpringMVC
项目名称《学生教务系统》
实现技术mybatis+Spring+SpringMVC+mysql+Servlet+jquery+bootStrap+js+Maven+tomcat等技术

3、数据库表设计

-- 创建员工表
create table t_emp(
id int primary key auto_increment,
name varchar(20) not null,
salary double not null,
age int not null
)-- 添加员工数据
insert into t_emp values(null,'王恒杰',20000,21);
insert into t_emp values(null,'杨福君',9000,19);
-- 查询员工数据
select * from t_emp;-- 创建管理员表
create table t_admin(id    int  primary key auto_increment,username varchar(20),password varchar(50)
)
-- 添加数据
insert into t_admin values(null,'王恒杰','123456');
-- 查询
select * from t_admin

4、Maven导入项目所依赖的jar包

  <!--junit--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-expression</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>4.3.2.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>4.3.2.RELEASE</version></dependency><!--springmvc核心依赖--><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>4.3.2.RELEASE</version></dependency><!--servlet-api--><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency><!--jsp--><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.1</version></dependency><!--jstl标签库--><dependency><groupId>jstl</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><!--mysql驱动jar--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.16</version></dependency><!--mybatis相关依赖--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.4.6</version></dependency><!--mybatis和spring的整合jar--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>1.3.1</version></dependency>

5、Spring+mybatis整合工厂(applicationContext.xml)

    <!--1.开启注解扫描--><context:component-scan base-package="com.tjcu.whj"></context:component-scan><!--2.加载 jdbc.properties小配置文件--><context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder><!--3.加载数据源--><bean class="com.alibaba.druid.pool.DruidDataSource" name="dataSource"><property name="driverClassName" value="${jdbc.driver}"></property><property name="url" value="${jdbc.url}"></property><property name="username" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property></bean><!--4.SqlSessionFactory--><bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory"><!--1.依赖于数据源--><property name="dataSource" ref="dataSource"></property><!--2:mapper文件--><property name="mapperLocations" value="classpath:com/tjcu/mapper/*DaoMapper.xml"></property><!--3.别名--><property name="typeAliasesPackage" value="com.tjcu.whj.entity"></property></bean><!--5.dao--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!--sqlSessionFactory--><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property><!--依赖于DAO接口类型  --><property name="basePackage" value="com.tjcu.whj.dao"></property></bean><!--6.事务管理器--><bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager"><property name="dataSource" ref="dataSource"></property></bean><!--7.开启注解式事务控制--><tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>

6、Spring+SpringMVC整合工厂(Spring-mvc.xml)

  <!--1.开启注解式扫描--><context:component-scan base-package="com.tjcu.whj"></context:component-scan><!--2.注册处理器映射器(解析URL路径)handlerMapping,处理器适配器:参数处理handlerAdapter--><mvc:annotation-driven/><!--3.注册视图解析器--><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><!--前缀--><property name="prefix" value="/"></property><!--后缀--><property name="suffix" value=".jsp"></property></bean><!--4.处理静态资源拦截问题--><mvc:default-servlet-handler/>

二、管理员登录/注册模块功能开发

  • 功能模块:登录,注册,注销,密码加密

  • 注册示意图

  • 登录示意图

1、dao层(adminDao.java)

public interface AdminDao {/*** 登录* @param admin* @return*/public Admin login(Admin admin);/***  注册* @param admin*/public void register(Admin admin);
}

2、Service层

(1)adminService接口层
public interface AdminService {/*** 登录* @param admin* @return*/public Admin login(Admin admin);/***  注册* @param admin*/public void register(Admin admin);
}
(2)adminServiceImpl实现类
@Service("adminService")
@Transactional
public class AdminServiceImpl implements AdminService {@Autowiredprivate AdminDao adminDao;@Overridepublic Admin login(Admin admin) {return adminDao.login(admin);}@Overridepublic void register(Admin admin) {adminDao.register(admin);}
}

3、功能测试(adminTest)

public class AdminTest {@Testpublic void login(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");AdminService adminService = (AdminService) context.getBean("adminService");Admin admin = new Admin(null,null, "王恒杰", "123456",true);Admin login = adminService.login(admin);System.out.println(login);}@Testpublic void register(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");AdminService adminService = (AdminService) context.getBean("adminService");Admin admin = new Admin(null, "风犬少年","邓正武", "234567",true);adminService.register(admin);}
}

4、Controller层

@Controller("adminController")
@RequestMapping("admin")
public class AdminController {/*** 将adminService到AdminController中*/@Autowiredprivate AdminService adminService;/*** 登录* @param admin* @return*/@RequestMapping("login")public String login(Admin admin,HttpServletRequest request){String password = MD5Utils.md5(admin.getPassword());admin.setPassword(password);Admin admin1 = adminService.login(admin);System.out.println(admin1);if(admin1!=null){request.getSession().setAttribute("admin",admin1);return "redirect:/emp/show";}return "redirect:/login.jsp";}/***  注册* @param admin*/@RequestMapping("register")public String register(Admin admin){String password = MD5Utils.md5(admin.getPassword());admin.setPassword(password);adminService.register(admin);return "redirect:/login.jsp";}/*** 注销登录* @return*/@RequestMapping("destroy")public String destroy(HttpServletRequest request){request.getSession().invalidate();return "redirect:/login.jsp";}}

三、员工增删改查功能模块的开发

  • 员工的增删改查功能

  • 员工展示页面

  • 添加员工示意图

  • 修改员工示意图

1、dao层(empDao.java)

public interface EmpDao {/*** 添加员工** @param emp*/public void insert(Emp emp);/*** 删除员工* @param id*/public void deleteById(Integer id);/*** 展示员工* @return*/public List<Emp> showEmp();/*** 修改员工* @param emp*/public void updateEmp(Emp emp);/*** 数据回显* @param id* @return*/public Emp selectEmpById(Integer id);
}

2、Service层

(1)empService接口层
public interface EmpService {/*** 添加员工** @param emp*/public void insert(Emp emp);/*** 删除员工* @param id*/public void deleteById(Integer id);/*** 展示员工* @return*/public List<Emp> showEmp();/*** 修改员工* @param emp*/public void updateEmp(Emp emp);/*** 数据回显* @param id* @return*/public Emp selectEmpById(Integer id);
}
(2)empServiceImpl实现类
@Service("empService")
/*** 控制事务*/
@Transactional
public class EmpServiceImpl implements EmpService {/*** 将empDao注入进@Service组件中*/@Autowiredprivate EmpDao empDao;public void setEmpDao(EmpDao empDao) {this.empDao = empDao;}@Overridepublic void insert(Emp emp) {empDao.insert(emp);}@Overridepublic void deleteById(Integer id) {empDao.deleteById(id);}@Override@Transactional(propagation = Propagation.SUPPORTS)public List<Emp> showEmp() {return empDao.showEmp();}@Overridepublic void updateEmp(Emp emp) {empDao.updateEmp(emp);}@Override@Transactional(propagation = Propagation.SUPPORTS)public Emp selectEmpById(Integer id) {return empDao.selectEmpById(id);}
}

3、功能测试(EmpTest)

public class EmpTest {/*** 添加员工*/@Testpublic void insert(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");EmpService empService = (EmpService) context.getBean("empService");Emp emp = new Emp(null,"邓正武",2000d,22);empService.insert(emp);}/*** 删除员工*/@Testpublic void deleteById(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");EmpService empService = (EmpService) context.getBean("empService");empService.deleteById(4);}/*** 展示员工* @return*/@Testpublic void showEmp(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");EmpService empService = (EmpService) context.getBean("empService");List<Emp> emps = empService.showEmp();for (Emp emp : emps) {System.out.println(emp);}}/*** 修改员工*/@Testpublic void updateEmp(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");EmpService empService = (EmpService) context.getBean("empService");Emp emp = new Emp(3,"邓正武",38000d,23);empService.updateEmp(emp);}/*** 数据回显* @return*/@Testpublic void selectEmpById(){ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");EmpService empService = (EmpService) context.getBean("empService");Emp emp = empService.selectEmpById(1);System.out.println(emp);}
}

4、Controller层

@Controller("emoController")
@RequestMapping("emp")
public class EmpController {/*** 注入empService在EmpController中*/@Autowiredprivate EmpService empService;/*** 添加员工** @param emp*/@RequestMapping("insert")public String insert(Emp emp){empService.insert(emp);return "redirect:/emp/show";}/*** 删除员工* @param emp*/@RequestMapping("delete")public String  deleteById(Emp emp){empService.deleteById(emp.getId());return "redirect:/emp/show";}/*** 展示员工* @return*/@RequestMapping("show")public String showEmp(Model model){//调用业务方法List<Emp> emps = empService.showEmp();//作用域model.addAttribute("emps",emps);return "emplist";}/*** 修改员工* @param emp*/@RequestMapping("update")public String  updateEmp(Emp emp){empService.updateEmp(emp);return "redirect:/emp/show";}/*** 数据回显* @param id* @return*/@RequestMapping("select")public String selectEmpById(Integer id,Model model){Emp emp = empService.selectEmpById(id);model.addAttribute("emp",emp);return "updateEmp";}
}

完整代码下载地址SSM实战项目,人事管理系统源码+数据库+使用说明

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/191584.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python zip函数及用法与lambda表达式及用法

Python zip函数及用法 zip() 函数可以把两个列表“压缩”成一个 zip 对象&#xff08;可迭代对象&#xff09;&#xff0c;这样就可以使用一个循环并行遍历两个列表。为了测试 zip() 函数的功能&#xff0c;我们可以先在交互式解释器中“试验”一下该函数的功能。 >>&g…

软件工程期末复习(1)

学习资料 软件工程知识点总结_嘤桃子的博客-CSDN博客 软件工程学习笔记_软件工程导论第六版张海藩pdf-CSDN博客 【软件工程】软件工程期末试卷习题课讲解&#xff01;&#xff01;_哔哩哔哩_bilibili 【拯救者】软件工程速成(期末考研复试软考)均适用. 支持4K_哔哩哔哩_bil…

redis单线程为什么这么快

redis单线程为什么这么快 redis是使用的单线程来进行操作的&#xff0c;因为所有的数据都是在内存中的&#xff0c;内存操作特别快。而且单线程避免了多线程切换性能损耗问题 单线程如何处理并发客户端连接&#xff1f; redis利用epoll来实现IO多路复用&#xff0c;将连接信息和…

【halcon】C# halcon 内存暴增

1 读取图片需要及时手动释放 一个6M的图片通过halcon进行加载&#xff0c;大约会消耗200M的内存&#xff0c;如果等待GC回收&#xff0c;而你又在不停的读取图片&#xff0c;你的内存占用&#xff0c;将在短时间内飙升。 2 halcon控件显示图片需要清空。 /// <summary>…

dp-带权活动选择

Description 给定n个活动&#xff0c;活动ai表示为一个三元组(si,fi,vi)&#xff0c;其中si表示活动开始时间&#xff0c;fi表示活动的结束时间&#xff0c;vi表示活动的权重, si<fi。带权活动选择问题是选择一些活动&#xff0c;使得任意被选择的两个活动ai和aj执行时间互不…

dataframe.values.tolist() 举例说明

dataframe.values.tolist() 是将 Pandas DataFrame 中的数据转换为嵌套的 Python 列表&#xff08;list of lists&#xff09;。这将返回一个包含 DataFrame 所有行和列的嵌套列表。以下是一个简单的例子&#xff1a; 假设有如下的 DataFrame&#xff1a; import pandas as p…

【Unity记录】EDM4U(External Dependency Manager)使用说明

GitHub - googlesamples/unity-jar-resolver: Unity plugin which resolves Android & iOS dependencies and performs version management 引入谷歌包时发现有这个玩意&#xff0c;主要用途是自动搜索工程内任意文件夹下的Editor/*Dependencies.xml文件 <dependencie…

基于eBPF检测内核模块安装行为

本文实现一个简单的示例&#xff0c;展示了如何编写一个eBPF程序来检测未知内核模块的安装行为。 首先&#xff0c;请确保系统已安装eBPF工具链。然后&#xff0c;创建一个名为unknown_module_detection.c的C文件&#xff0c;并使用以下代码填充内容&#xff1a; c #include …

D*算法学习

系列文章目录 A*算法学习-CSDN博客 弗洛伊德算法&#xff08;Floyd&#xff09;和路径平滑弗洛伊德算法&#xff08;Smooth Floyd&#xff09;学习-CSDN博客 目录 系列文章目录 前言 一、D*算法是什么&#xff1f; 二、D* 算法是对 A* 算法的改进 三、增量搜索是什么 总…

梯度爆炸梯度消失

梯度消失和梯度爆炸是深度学习中常见的问题&#xff0c;与神经网络的训练相关。这两个问题都涉及到梯度在反向传播过程中的传递。 梯度消失&#xff08;Gradient Vanishing&#xff09;&#xff1a; 当神经网络较深时&#xff0c;反向传播过程中梯度可能逐层减小&#xff0c;最…

【FMC139】青翼科技基于VITA57.1标准的4路500MSPS/1GSPS/1.25GSPS采样率14位AD采集FMC子卡模块

板卡概述 FMC139是一款基于VITA57.1标准规范的JESD204B接口FMC子卡模块&#xff0c;该模块可以实现4路14-bit、500MSPS/1GSPS ADC采集功能。该板卡ADC器件采用ADI公司的AD9680芯片,全功率-3dB模拟输入带宽可达2GHz。该ADC与FPGA的主机接口通过8通道的高速串行GTX收发器进行互联…

Python模块与Linux stat 命令:双剑合璧的文件系统探索

简介&#xff1a;在Linux和Unix-like系统中&#xff0c;stat命令用于获取文件或目录的详细属性信息&#xff0c;包括但不限于大小、所有权、权限和时间戳。同样&#xff0c;在Python编程中&#xff0c;我们也有多个模块&#xff08;例如os、pathlib等&#xff09;提供了与stat类…

来CSDN一周年啦!!!

各位CSDN的uu们你们好呀&#xff0c;今天是小雅兰来到CSDN创作的一周年啦&#xff0c;时间&#xff0c;说长不长&#xff0c;说短也不短&#xff0c;在这一年中&#xff0c;我认为我也收获了一些很有价值的东西吧&#xff01;&#xff01; 一周年了&#xff0c;该创作的还得继续…

基于PAM自定义ssh登陆认证

以下是一个基于Linux PAM认证SSH登录的动态链接库&#xff08;.so&#xff09;模块的示例代码&#xff0c;使用C语言编写&#xff0c;其中包括对用户名、密码以及约定的口令的认证&#xff1a; c #include <stdio.h> #include <stdlib.h> #include <string.h&g…

【PTA-C语言】实验四-循环结构II

如果代码存在问题&#xff0c;麻烦大家指正 ~ ~有帮助麻烦点个赞 ~ ~ 实验四-循环结构II 7-1 跟奥巴马一起画方块&#xff08;分数 15&#xff09;7-2 打印九九口诀表&#xff08;分数 10&#xff09;7-3 求符合给定条件的整数集&#xff08;分数 15&#xff09;7-4 求特殊方程…

AGI智能新时代,大模型为软件开发带来范式变革

导语 | 人工智能作为新一轮科技革命和产业变革的重要驱动力量&#xff0c;尤其是在当下新一轮 AI 大模型、生成式 AI 浪潮背景下&#xff0c;重视通用人工智能&#xff08;AGI&#xff09;成为行业的共识。在当前&#xff0c; AGI 技术背后的逻辑究竟是怎样的&#xff1f;技术创…

力扣二叉树--第三十六天

前言 两天没写题了&#xff0c;期末月&#xff0c;压力有点大&#xff0c;休息一下&#xff0c;释放一下压力。焦虑常在&#xff0c;调整好心态啊&#xff01;度过这一个月。写中序遍历的时候&#xff0c;发现自己竟然对树是怎么遍历的很模糊&#xff01;&#xff01;&#xf…

CF688A Opponents

Opponents 题面翻译 问题描述 小白有 n 个对手&#xff0c;他每天都要和这些对手PK。对于每一天&#xff0c;如果 n 个对手全部到齐&#xff0c;那么小白就输了一场&#xff0c;否则小白就赢了一场。特别的&#xff0c;如果某天一个对手都没有到&#xff0c;也算小白赢。现在…

杨志丰:OceanBase助力企业应对数据库转型深水区挑战

11 月 16 日&#xff0c;OceanBase 在北京顺利举办 2023 年度发布会&#xff0c;正式宣布&#xff1a;将持续践行“一体化”产品战略&#xff0c;为关键业务负载打造一体化数据库。OceanBase 产品总经理杨志丰发表了《助力企业应对数据库转型深水区挑战》主题演讲。 以下为演讲…

【代码】基于改进差分进化算法的微电网调度研究matlab

程序名称&#xff1a;基于改进差分进化算法的微电网调度研究 实现平台&#xff1a;matlab 代码简介&#xff1a;了进一步提升差分进化算法的优化性能,结合粒子群(PSO)算法的进化机制,提出一种混合多重随机变异粒子差分进化算法(DE-PSO)。所提算法不仅使用粒子群差分变异策略和…