基于Spring MVC + Spring + MyBatis的【学生信息管理系统】

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

2、项目Java代码


目录结构

student

在这里插入图片描述

JAR包:

在这里插入图片描述在这里插入图片描述

src

com.controller

StudentController.java

package com.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

import com.dao.StudentMapper;

import com.entity.Student;

import com.service.StudentService;

@Controller

public class StudentController {

@Resource

StudentService service;

@RequestMapping(“/selectStudent”)

public ModelAndView selectStudent(String keyword) {

List studentList=service.selectAll(keyword);

if (keyword==null||keyword.trim().equals(“”)) {

keyword=“”;

}

System.out.println(“123456”);

ModelAndView modelAndView = new ModelAndView();

modelAndView.addObject(“studentList”, studentList);

modelAndView.setViewName(“student”);

return modelAndView;

}

@RequestMapping(“/delStudent”)

public String delStudent(int id) {

int del=service.delStudent(id);

return “redirect:/selectStudent.do”;

}

@RequestMapping(“/jumpInsert”)

public String jumpInsert() {

return “addStudent”;

}

@RequestMapping(“/insertStudent”)

public String insertStudent(Student student) {

int add=service.insertStudent(student);

return “redirect:/selectStudent.do”;

}

}

com.dao

StudentMapper.java

package com.dao;

import com.entity.Student;

import java.util.List;

public interface StudentMapper {

int deleteByPrimaryKey(Integer id);

int insert(Student record);

Student selectByPrimaryKey(Integer id);

List selectAll();

int updateByPrimaryKey(Student record);

List likeSelect(String keyword);

}

StudentMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>

delete from student

where id = #{id,jdbcType=INTEGER}

insert into student (id, name, age,

classes, birth)

values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER},

#{classes,jdbcType=VARCHAR}, #{birth,jdbcType=VARCHAR})

update student

set name = #{name,jdbcType=VARCHAR},

age = #{age,jdbcType=INTEGER},

classes = #{classes,jdbcType=VARCHAR},

birth = #{birth,jdbcType=VARCHAR}

where id = #{id,jdbcType=INTEGER}

select id, name, age, classes, birth

from student

where id = #{id,jdbcType=INTEGER}

select id, name, age, classes, birth

from student

select id, name, age, classes, birth

from student where name LIKE “%”#{name}“%”

com.entity

Student.java

package com.entity;

public class Student {

private Integer id;

private String name;

private Integer age;

private String classes;

private String birth;

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name == null ? null : name.trim();

}

public Integer getAge() {

return age;

}

public void setAge(Integer age) {

this.age = age;

}

public String getClasses() {

return classes;

}

public void setClasses(String classes) {

this.classes = classes == null ? null : classes.trim();

}

public String getBirth() {

return birth;

}

public void setBirth(String birth) {

this.birth = birth == null ? null : birth.trim();

}

}

com.generator

Generator.java

package com.generator;

import java.io.IOException;

import java.io.InputStream;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;

import org.mybatis.generator.api.MyBatisGenerator;

import org.mybatis.generator.config.Configuration;

import org.mybatis.generator.config.xml.ConfigurationParser;

import org.mybatis.generator.exception.InvalidConfigurationException;

import org.mybatis.generator.exception.XMLParserException;

import org.mybatis.generator.internal.DefaultShellCallback;

public class Generator {

/*

  • targetRuntime=“MyBatis3Simple”, 不生成Example

*/

public void generateMyBatis() {

//MBG执行过程中的警告信息

List warnings = new ArrayList();

//当生成的代码重复时,覆盖原代码

boolean overwrite = true ;

//String generatorFile = “/generator/generatorConfig.xml”;

String generatorFile = “/generatorConfig.xml”;

//读取MBG配置文件

InputStream is = Generator.class.getResourceAsStream(generatorFile);

ConfigurationParser cp = new ConfigurationParser(warnings);

Configuration config;

try {

config = cp.parseConfiguration(is);

DefaultShellCallback callback = new DefaultShellCallback(overwrite);

//创建MBG

MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);

//执行生成代码

myBatisGenerator.generate(null);

} catch (IOException e) {

e.printStackTrace();

} catch (XMLParserException e) {

e.printStackTrace();

} catch (InvalidConfigurationException e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

} catch (InterruptedException e) {

e.printStackTrace();

}

for (String warning : warnings) {

System.out.println(warning);

}

}

public static void main(String[] args) {

Generator generator = new Generator();

generator.generateMyBatis();

}

}

com.service

StudentService.java

package com.service;

import java.util.List;

import com.entity.Student;

public interface StudentService {

//查询

List selectAll(String keyword);

//删除

int delStudent(int id);

//添加

int insertStudent(Student student);

}

com.service.imp

StudentServiceImpl.java

package com.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dao.StudentMapper;

import com.entity.Student;

import com.service.StudentService;

@Service

public class StudentServiceImpl implements StudentService {

@Resource

StudentMapper mapper;

@Override

// 查询

public List selectAll(String keyword) {

if (keyword == null || keyword.trim().equals(“”)) {

List selectAll = mapper.selectAll();

return selectAll;

} else {

List likeSelect = mapper.likeSelect(keyword);

return likeSelect;

}

}

// 删除

@Override

public int delStudent(int id) {

int del = mapper.deleteByPrimaryKey(id);

return del;

}

// 添加

@Override

public int insertStudent(Student student) {

int insert = mapper.insert(student);

return insert;

}

}

mybatis

sqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
spring

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xmlns=“http://www.springframework.org/schema/beans”

xmlns:p=“http://www.springframework.org/schema/p”

xmlns:context=“http://www.springframework.org/schema/context”

xmlns:aop=“http://www.springframework.org/schema/aop”

xmlns:tx=“http://www.springframework.org/schema/tx”

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-4.2.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-4.2.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">

<context:property-placeholder location=“classpath:jdbc.properties”></context:property-placeholder>

<tx:annotation-driven transaction-manager=“transactionManager” />

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xmlns=“http://www.springframework.org/schema/beans”

xmlns:context=“http://www.springframework.org/schema/context”

xmlns:aop=“http://www.springframework.org/schema/aop”

xmlns:tx=“http://www.springframework.org/schema/tx”

xmlns:mvc=“http://www.springframework.org/schema/mvc”

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-4.2.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-4.2.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-4.2.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">

<context:component-scan base-package=“com” />

spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xmlns=“http://www.springframework.org/schema/beans”

xmlns:context=“http://www.springframework.org/schema/context”

xmlns:aop=“http://www.springframework.org/schema/aop”

xmlns:tx=“http://www.springframework.org/schema/tx”

xmlns:mvc=“http://www.springframework.org/schema/mvc”

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-4.2.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-4.2.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-4.2.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">

<context:component-scan base-package=“com.controller” />

<mvc:annotation-driven />

generatorConfig.xml

最后

总而言之,面试官问来问去,问的那些Redis知识点也就这么多吧,复习的不够到位,知识点掌握不够熟练,所以面试才会卡壳。将这些Redis面试知识解析以及我整理的一些学习笔记分享出来给大家参考学习

还有更多学习笔记面试资料也分享如下:

都是“Redis惹的祸”,害我差点挂在美团三面,真是“虚惊一场”

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
ng-tx-4.2.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">

<context:component-scan base-package=“com.controller” />

<mvc:annotation-driven />

generatorConfig.xml

最后

总而言之,面试官问来问去,问的那些Redis知识点也就这么多吧,复习的不够到位,知识点掌握不够熟练,所以面试才会卡壳。将这些Redis面试知识解析以及我整理的一些学习笔记分享出来给大家参考学习

还有更多学习笔记面试资料也分享如下:

[外链图片转存中…(img-LqI2xHgH-1713460661233)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-LRc8KxSc-1713460661234)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值