发表于: 2020-06-25 21:49:20
1 1747
今天完成的事情:整合SSM 增删改查
新建表
创建实体类
package com.jnshu.model;
public class Student {
private Long ID ;
private String Name;
private Long QQ ;
private String Type ;
private Long Time ;
private String School ;
private Long Num ;
private String Link ;
private String Wish ;
private String Leader ;
private Long Create_at ;
private Long Update_at ;
@Override
public String toString() {
return "Student{" +
"ID=" + ID +
", Name='" + Name + '\'' +
", QQ=" + QQ +
", Type='" + Type + '\'' +
", Time=" + Time +
", School='" + School + '\'' +
", Num=" + Num +
", Link='" + Link + '\'' +
", Wish='" + Wish + '\'' +
", Leader='" + Leader + '\'' +
", Create_at=" + Create_at +
", Update_at=" + Update_at +
'}';
}
public Long getID() {
return ID;
}
public void setID(Long ID) {
this.ID = ID;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public Long getQQ() {
return QQ;
}
public void setQQ(Long QQ) {
this.QQ = QQ;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public Long getTime() {
return Time;
}
public void setTime(Long time) {
Time = time;
}
public String getSchool() {
return School;
}
public void setSchool(String school) {
School = school;
}
public Long getNum() {
return Num;
}
public void setNum(Long num) {
Num = num;
}
public String getLink() {
return Link;
}
public void setLink(String link) {
Link = link;
}
public String getWish() {
return Wish;
}
public void setWish(String wish) {
Wish = wish;
}
public String getLeader() {
return Leader;
}
public void setLeader(String leader) {
Leader = leader;
}
public Long getCreate_at() {
return Create_at;
}
public void setCreate_at(Long create_at) {
Create_at = create_at;
}
public Long getUpdate_at() {
return Update_at;
}
public void setUpdate_at(Long update_at) {
Update_at = update_at;
}
}
编写DAO
package com.jnshu.Dao;
import com.jnshu.Model.Student;
import java.util.List;
public interface StudentMapper {
void Insert(Student student);
void Delete(Long ID);
void Update(Student student);
Student SelectById(Long ID);
List<Student> GetAllStudent();
}
接口映射文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- mybatis的实体类映射对象 -->
<mapper namespace="com.jnshu.Dao.StudentMapper">
<!-- 根据ID查询 -->
<select id="SelectById" parameterType="Long" resultType="com.jnshu.Model.Student">
select * from studentlist where ID=#{ID}
</select>
<!-- 查询所有 -->
<select id="GetAllStudent" resultType="com.jnshu.Model.Student">
select * from studentlist
</select>
<!-- 删除 -->
<delete id="Delete" parameterType="Long">
delete from studentlist where ID= #{ID}
</delete>
<!-- 修改 -->
<update id="Update" parameterType="com.jnshu.Model.Student">
update studentlist set name = #{name} where ID = #{ID}
</update>
<!-- 添加 -->
<insert id="Insert" parameterType="com.jnshu.Model.Student">
insert into studentlist (ID,Name,QQ,Type,Time,School,Num,Link,Wish,Leader,Create_at,Update_at)values (#{ID},#{Name},#{QQ},#{Type},#{Time},#{School},#{Num},#{Link},#{Wish},#{Leader},#{Create_at},#{Update_at})
</insert>
</mapper>
package com.jnshu.Service;
import com.jnshu.Model.Student;
import java.util.List;
public interface StudentService {
void Insert(Student student);
void Delete(Long ID);
void Update(Student student);
Student SelectById(Long ID);
List<Student> GetAllStudent();
}
明天计划的事情:整合SPRINGMVC
遇到的问题:异常Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0'
idea自动导入命名空间时出现了问题,导成了↓(含 cache) 这种
收获:复习了一遍遗忘的任务2.
评论