资讯专栏INFORMATION COLUMN

SSM实战项目:人事管理系统(蓝色版)【附源代码】

bang590 / 2326人阅读

?程序员小王的博客:程序员小王的博客
? 欢迎点赞 ? 收藏 ⭐留言 ?
? 如有编辑错误联系作者,如果有比较好的文章欢迎分享给我,我会取其精华去其糟粕
?java自学的学习路线:java自学的学习路线

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

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

源代码在githee仓库:SSM实战项目:人事管理系统(蓝色版)

1、整个项目实现功能

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

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包

          <dependency>            <groupId>junitgroupId>            <artifactId>junitartifactId>            <version>4.11version>            <scope>testscope>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-coreartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-contextartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-context-supportartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-jdbcartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-aopartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-beansartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-expressionartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-aspectsartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-txartifactId>            <version>4.3.2.RELEASEversion>        dependency>        <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-webartifactId>            <version>4.3.2.RELEASEversion>        dependency>                <dependency>            <groupId>org.springframeworkgroupId>            <artifactId>spring-webmvcartifactId>            <version>4.3.2.RELEASEversion>        dependency>                <dependency>            <groupId>javax.servletgroupId>            <artifactId>servlet-apiartifactId>            <version>2.5version>            <scope>providedscope>        dependency>                <dependency>            <groupId>javax.servlet.jspgroupId>            <artifactId>jsp-apiartifactId>            <version>2.1version>        dependency>                <dependency>            <groupId>jstlgroupId>            <artifactId>jstlartifactId>            <version>1.2version>        dependency>                <dependency>            <groupId>mysqlgroupId>            <artifactId>mysql-connector-javaartifactId>            <version>8.0.16version>        dependency>                <dependency>            <groupId>org.mybatisgroupId>            <artifactId>mybatisartifactId>            <version>3.4.6version>        dependency>                <dependency>            <groupId>org.mybatisgroupId>            <artifactId>mybatis-springartifactId>            <version>1.3.1version>        dependency>

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

        <context:component-scan base-package="com.tjcu.whj">context:component-scan>          <context:property-placeholder location="classpath:jdbc.properties">context:property-placeholder>           <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>        <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">                <property name="dataSource" ref="dataSource">property>                <property name="mapperLocations" value="classpath:com/tjcu/mapper/*DaoMapper.xml">property>                <property name="typeAliasesPackage" value="com.tjcu.whj.entity">property>    bean>            <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">                <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory">property>                <property name="basePackage" value="com.tjcu.whj.dao">property>    bean>            <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">        <property name="dataSource" ref="dataSource">property>    bean>            <tx:annotation-driven transaction-manager="transactionManager">tx:annotation-driven>

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

      <context:component-scan base-package="com.tjcu.whj">context:component-scan>        <mvc:annotation-driven/>        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">                <property name="prefix" value="/">property>                <property name="suffix" value=".jsp">property>    bean>        <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")@Transactionalpublic class AdminServiceImpl implements AdminService {    @Autowired  private AdminDao adminDao;    @Override    public Admin login(Admin admin) {        return adminDao.login(admin);    }    @Override    public void register(Admin admin) {         adminDao.register(admin);    }}

3、功能测试(adminTest)

public class AdminTest {    @Test    public 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);    }    @Test    public 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中     */    @Autowired    private 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.
            
                     
             
               

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/124037.html

相关文章

  • java基于ssm人事管理系统

    摘要:项目描述该项目包含了用户管理部门管理职位管理员工管理公告管理下载中心等多个模块页面使用框架完成动态功能用户管理部门管理等模块包含了项目开发中常用的增删改查动作下载中心包含了的文件上传下载等功能运行环境项目技术数据库文件 ...

    wuaiqiu 评论0 收藏0
  • Python文章合集 | 这些项目里肯定有你的新宠(入门到实战、游戏、Turtle、案例等)

    摘要:有趣好玩的个入门题案例都在这里等你下载。趣味连连看经典版童年经典火影忍者连连看,无需下载,在线可玩小游戏植物大战僵尸游戏真的有毒戒不掉啊实战项目实战项目做一个刮刮乐案例,一不小心着实惊艳到我了。 导语 为了大家能相应的找到自己那方面的文章,这边小编进行了文章的汇总合集,也特别感谢我的粉丝们...

    derek_334892 评论0 收藏0
  • Java3y文章目录导航

    摘要:前言由于写的文章已经是有点多了,为了自己和大家的检索方便,于是我就做了这么一个博客导航。 前言 由于写的文章已经是有点多了,为了自己和大家的检索方便,于是我就做了这么一个博客导航。 由于更新比较频繁,因此隔一段时间才会更新目录导航哦~想要获取最新原创的技术文章欢迎关注我的公众号:Java3y Java3y文章目录导航 Java基础 泛型就这么简单 注解就这么简单 Druid数据库连接池...

    KevinYan 评论0 收藏0
  • 一位大佬的亲身经历总结:简历和面试的技巧

    摘要:我觉得了解简历和面试的技巧可以帮助你更好的去学习重要的知识点以及更好地去准备面试以及面试,说实话,我个人觉得这些东西还挺重要的。在本文里,我将介绍我这段时间里更新简历和面试的相关经历。 分享一篇很不错的文章!本文作者曾经写过《Java Web轻量级开发面试教程》和 《Java核心技术及面试指南》这两本书。我觉得了解简历和面试的技巧可以帮助你更好的去学习重要的知识点以及更好地去准备面试以...

    pingan8787 评论0 收藏0
  • java实现沙箱测试环境支付宝支付(demo)和整合微信支付和支付宝支付到ssm环境全过程(源码)

    摘要:设置和其中密钥需要自己生成,和支付宝网关是已经给好的,网关有字样,表明是用于开发测试。上面就是将阿里支付宝支付整合到的全过程了,如果还有什么疑问,可以留言或者私信我源代码下载链接密码 文章有不当之处,欢迎指正,如果喜欢微信阅读,你也可以关注我的微信公众号:好好学java,获取优质学习资源。 一、支付宝测试环境代码测试 1.下载电脑网站的官方demo: 下载地址:https://docs...

    channg 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<