diff --git a/equipment-SpringProject/equipment-SpringProject.iml b/equipment-SpringProject/equipment-SpringProject.iml index bb2779b..fec6e89 100644 --- a/equipment-SpringProject/equipment-SpringProject.iml +++ b/equipment-SpringProject/equipment-SpringProject.iml @@ -10,5 +10,9 @@ + + + + \ No newline at end of file diff --git a/equipment-SpringProject/src/applicationContext-aop.xml b/equipment-SpringProject/src/applicationContext-aop.xml new file mode 100644 index 0000000..452bcc1 --- /dev/null +++ b/equipment-SpringProject/src/applicationContext-aop.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/equipment-SpringProject/src/applicationContext.xml b/equipment-SpringProject/src/applicationContext.xml new file mode 100644 index 0000000..bb400f1 --- /dev/null +++ b/equipment-SpringProject/src/applicationContext.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/equipment-SpringProject/src/bean-aop-xml.xml b/equipment-SpringProject/src/bean-aop-xml.xml deleted file mode 100644 index f855763..0000000 --- a/equipment-SpringProject/src/bean-aop-xml.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/equipment-SpringProject/src/bean-di-annotation.xml b/equipment-SpringProject/src/bean-di-annotation.xml deleted file mode 100644 index 0efcc3f..0000000 --- a/equipment-SpringProject/src/bean-di-annotation.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/equipment-SpringProject/src/bean-di-xml.xml b/equipment-SpringProject/src/bean-di-xml.xml index e2b8fc2..398c854 100644 --- a/equipment-SpringProject/src/bean-di-xml.xml +++ b/equipment-SpringProject/src/bean-di-xml.xml @@ -1,22 +1,60 @@ - - - - - + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/equipment-SpringProject/src/bean-first.xml b/equipment-SpringProject/src/bean-first.xml deleted file mode 100644 index 8dd278e..0000000 --- a/equipment-SpringProject/src/bean-first.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/equipment-SpringProject/src/bean-ioc.xml b/equipment-SpringProject/src/bean-ioc.xml index 9481343..3c35f32 100644 --- a/equipment-SpringProject/src/bean-ioc.xml +++ b/equipment-SpringProject/src/bean-ioc.xml @@ -1,45 +1,58 @@ - + - + - - - + + + - - - - - - - - - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Appointment.java b/equipment-SpringProject/src/com/ssm/aop/xml/Appointment.java new file mode 100644 index 0000000..c2ddfbf --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/aop/xml/Appointment.java @@ -0,0 +1,37 @@ +package com.ssm.aop.xml; + +import java.util.Date; + +public class Appointment { + private String appointmentId; + private String username; + private String labId; + private Date startTime; + private Date endTime; + private String purpose; + + public Appointment() {} + + public String getAppointmentId() { return appointmentId; } + public void setAppointmentId(String appointmentId) { this.appointmentId = appointmentId; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public Date getStartTime() { return startTime; } + public void setStartTime(Date startTime) { this.startTime = startTime; } + public Date getEndTime() { return endTime; } + public void setEndTime(Date endTime) { this.endTime = endTime; } + public String getPurpose() { return purpose; } + public void setPurpose(String purpose) { this.purpose = purpose; } + + public void printInfo() { + System.out.println("预约信息:"); + System.out.println("预约编号:" + appointmentId); + System.out.println("预约人:" + username); + System.out.println("实验室编号:" + labId); + System.out.println("开始时间:" + startTime); + System.out.println("结束时间:" + endTime); + System.out.println("用途:" + purpose); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Course.java b/equipment-SpringProject/src/com/ssm/aop/xml/Course.java deleted file mode 100644 index c176f30..0000000 --- a/equipment-SpringProject/src/com/ssm/aop/xml/Course.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ssm.aop.xml; - -public class Course { - private String courseId; - private String courseName; - private int credit; - private Teacher teacher; - - public void setCourseId(String courseId) { this.courseId = courseId; } - public void setCourseName(String courseName) { this.courseName = courseName; } - public void setCredit(int credit) { this.credit = credit; } - public void setTeacher(Teacher teacher) { this.teacher = teacher; } - - public void printInfo() { - System.out.println("课程编号:" + courseId); - System.out.println("课程名称:" + courseName); - System.out.println("学分:" + credit); - System.out.println("授课教师信息:工号:" + teacher.getTeacherId() + ",姓名:" + teacher.getName() + ",职称:" + teacher.getTitle()); - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Laboratory.java b/equipment-SpringProject/src/com/ssm/aop/xml/Laboratory.java new file mode 100644 index 0000000..06b72d1 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/aop/xml/Laboratory.java @@ -0,0 +1,31 @@ +package com.ssm.aop.xml; + +public class Laboratory { + private String labId; + private String labName; + private String location; + private int capacity; + private String status; + + public Laboratory() {} + + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public String getLabName() { return labName; } + public void setLabName(String labName) { this.labName = labName; } + public String getLocation() { return location; } + public void setLocation(String location) { this.location = location; } + public int getCapacity() { return capacity; } + public void setCapacity(int capacity) { this.capacity = capacity; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + public void printInfo() { + System.out.println("实验室信息:"); + System.out.println("实验室编号:" + labId); + System.out.println("实验室名称:" + labName); + System.out.println("位置:" + location); + System.out.println("容纳人数:" + capacity); + System.out.println("状态:" + status); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Log.java b/equipment-SpringProject/src/com/ssm/aop/xml/Log.java index c34d59d..cb0644e 100644 --- a/equipment-SpringProject/src/com/ssm/aop/xml/Log.java +++ b/equipment-SpringProject/src/com/ssm/aop/xml/Log.java @@ -3,9 +3,8 @@ package com.ssm.aop.xml; import org.aspectj.lang.JoinPoint; public class Log { - public void beforeAdvice(JoinPoint joinPoint) { - String className = joinPoint.getTarget().getClass().getName(); - String methodName = joinPoint.getSignature().getName(); - System.out.println("前置通知:模拟日志的记录...目标类是:" + className + ",被切入通知的目标方法为:" + methodName); + // 前置通知:在printInfo方法执行前输出日志 + public void beforeLog(JoinPoint joinPoint) { + System.out.println("【前置通知】模拟日志记录...目标类是:" + joinPoint.getTarget() + ",被切入通知的目标方法为:" + joinPoint.getSignature().getName()); } } \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Material.java b/equipment-SpringProject/src/com/ssm/aop/xml/Material.java new file mode 100644 index 0000000..75e5415 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/aop/xml/Material.java @@ -0,0 +1,31 @@ +package com.ssm.aop.xml; + +public class Material { + private String materialId; + private String materialName; + private String type; + private int stock; + private String unit; + + public Material() {} + + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getMaterialName() { return materialName; } + public void setMaterialName(String materialName) { this.materialName = materialName; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + public int getStock() { return stock; } + public void setStock(int stock) { this.stock = stock; } + public String getUnit() { return unit; } + public void setUnit(String unit) { this.unit = unit; } + + public void printInfo() { + System.out.println("材料信息:"); + System.out.println("材料编号:" + materialId); + System.out.println("材料名称:" + materialName); + System.out.println("类型:" + type); + System.out.println("库存:" + stock); + System.out.println("单位:" + unit); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/MaterialRecord.java b/equipment-SpringProject/src/com/ssm/aop/xml/MaterialRecord.java new file mode 100644 index 0000000..a3e43ba --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/aop/xml/MaterialRecord.java @@ -0,0 +1,37 @@ +package com.ssm.aop.xml; + +import java.util.Date; + +public class MaterialRecord { + private String recordId; + private String materialId; + private String operator; + private int nums; + private Date operateDate; + private String type; + + public MaterialRecord() {} + + public String getRecordId() { return recordId; } + public void setRecordId(String recordId) { this.recordId = recordId; } + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getOperator() { return operator; } + public void setOperator(String operator) { this.operator = operator; } + public int getNums() { return nums; } + public void setNums(int nums) { this.nums = nums; } + public Date getOperateDate() { return operateDate; } + public void setOperateDate(Date operateDate) { this.operateDate = operateDate; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + + public void printInfo() { + System.out.println("材料出入库记录:"); + System.out.println("记录编号:" + recordId); + System.out.println("材料编号:" + materialId); + System.out.println("操作人:" + operator); + System.out.println("操作数量:" + nums); + System.out.println("操作日期:" + operateDate); + System.out.println("操作类型:" + type); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/Teacher.java b/equipment-SpringProject/src/com/ssm/aop/xml/Teacher.java deleted file mode 100644 index 0f5feb7..0000000 --- a/equipment-SpringProject/src/com/ssm/aop/xml/Teacher.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.ssm.aop.xml; - -public class Teacher { - private String teacherId; - private String name; - private String title; - - public void setTeacherId(String teacherId) { this.teacherId = teacherId; } - public void setName(String name) { this.name = name; } - public void setTitle(String title) { this.title = title; } - - public String getTeacherId() { return teacherId; } - public String getName() { return name; } - public String getTitle() { return title; } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/TestAopXml.java b/equipment-SpringProject/src/com/ssm/aop/xml/TestAopXml.java index 3e4ec8e..89fdcbd 100644 --- a/equipment-SpringProject/src/com/ssm/aop/xml/TestAopXml.java +++ b/equipment-SpringProject/src/com/ssm/aop/xml/TestAopXml.java @@ -5,8 +5,27 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestAopXml { public static void main(String[] args) { - ApplicationContext context = new ClassPathXmlApplicationContext("bean-aop-xml.xml"); - Course course = context.getBean("course", Course.class); - course.printInfo(); + // 【唯一正确写法】从类路径加载配置文件 + ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-aop.xml"); + + System.out.println("===== 用户管理模块 ====="); + User user = (User) context.getBean("user"); + user.printInfo(); + + System.out.println("\n===== 材料管理模块 ====="); + Material material = (Material) context.getBean("material"); + material.printInfo(); + + System.out.println("\n===== 材料出入库管理模块 ====="); + MaterialRecord record = (MaterialRecord) context.getBean("materialRecord"); + record.printInfo(); + + System.out.println("\n===== 预约管理模块 ====="); + Appointment appointment = (Appointment) context.getBean("appointment"); + appointment.printInfo(); + + System.out.println("\n===== 实验室管理模块 ====="); + Laboratory lab = (Laboratory) context.getBean("laboratory"); + lab.printInfo(); } } \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/aop/xml/User.java b/equipment-SpringProject/src/com/ssm/aop/xml/User.java new file mode 100644 index 0000000..72d78d3 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/aop/xml/User.java @@ -0,0 +1,31 @@ +package com.ssm.aop.xml; + +public class User { + private String username; + private String userpass; + private String truename; + private int age; + private String role; + + public User() {} + + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getUserpass() { return userpass; } + public void setUserpass(String userpass) { this.userpass = userpass; } + public String getTruename() { return truename; } + public void setTruename(String truename) { this.truename = truename; } + public int getAge() { return age; } + public void setAge(int age) { this.age = age; } + public String getRole() { return role; } + public void setRole(String role) { this.role = role; } + + public void printInfo() { + System.out.println("用户信息:"); + System.out.println("用户名:" + username); + System.out.println("密码:" + userpass); + System.out.println("真实姓名:" + truename); + System.out.println("年龄:" + age); + System.out.println("角色:" + role); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/Appointment.java b/equipment-SpringProject/src/com/ssm/di/Appointment.java new file mode 100644 index 0000000..dd4c0a8 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/Appointment.java @@ -0,0 +1,37 @@ +package com.ssm.di; + +import java.util.Date; + +public class Appointment { + private String appointmentId; + private String username; + private String labId; + private Date startTime; + private Date endTime; + private String purpose; + + public Appointment() {} + + public String getAppointmentId() { return appointmentId; } + public void setAppointmentId(String appointmentId) { this.appointmentId = appointmentId; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public Date getStartTime() { return startTime; } + public void setStartTime(Date startTime) { this.startTime = startTime; } + public Date getEndTime() { return endTime; } + public void setEndTime(Date endTime) { this.endTime = endTime; } + public String getPurpose() { return purpose; } + public void setPurpose(String purpose) { this.purpose = purpose; } + + public void printInfo() { + System.out.println("预约信息:"); + System.out.println("预约编号:" + appointmentId); + System.out.println("预约人:" + username); + System.out.println("实验室编号:" + labId); + System.out.println("开始时间:" + startTime); + System.out.println("结束时间:" + endTime); + System.out.println("用途:" + purpose); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/Laboratory.java b/equipment-SpringProject/src/com/ssm/di/Laboratory.java new file mode 100644 index 0000000..904db63 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/Laboratory.java @@ -0,0 +1,31 @@ +package com.ssm.di; + +public class Laboratory { + private String labId; + private String labName; + private String location; + private int capacity; + private String status; + + public Laboratory() {} + + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public String getLabName() { return labName; } + public void setLabName(String labName) { this.labName = labName; } + public String getLocation() { return location; } + public void setLocation(String location) { this.location = location; } + public int getCapacity() { return capacity; } + public void setCapacity(int capacity) { this.capacity = capacity; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + public void printInfo() { + System.out.println("实验室信息:"); + System.out.println("实验室编号:" + labId); + System.out.println("实验室名称:" + labName); + System.out.println("位置:" + location); + System.out.println("容纳人数:" + capacity); + System.out.println("状态:" + status); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/Material.java b/equipment-SpringProject/src/com/ssm/di/Material.java new file mode 100644 index 0000000..941f958 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/Material.java @@ -0,0 +1,31 @@ +package com.ssm.di; + +public class Material { + private String materialId; + private String materialName; + private String type; + private int stock; + private String unit; + + public Material() {} + + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getMaterialName() { return materialName; } + public void setMaterialName(String materialName) { this.materialName = materialName; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + public int getStock() { return stock; } + public void setStock(int stock) { this.stock = stock; } + public String getUnit() { return unit; } + public void setUnit(String unit) { this.unit = unit; } + + public void printInfo() { + System.out.println("材料信息:"); + System.out.println("材料编号:" + materialId); + System.out.println("材料名称:" + materialName); + System.out.println("类型:" + type); + System.out.println("库存:" + stock); + System.out.println("单位:" + unit); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/MaterialRecord.java b/equipment-SpringProject/src/com/ssm/di/MaterialRecord.java new file mode 100644 index 0000000..fddd9db --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/MaterialRecord.java @@ -0,0 +1,37 @@ +package com.ssm.di; + +import java.util.Date; + +public class MaterialRecord { + private String recordId; + private String materialId; + private String operator; + private int nums; + private Date operateDate; + private String type; + + public MaterialRecord() {} + + public String getRecordId() { return recordId; } + public void setRecordId(String recordId) { this.recordId = recordId; } + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getOperator() { return operator; } + public void setOperator(String operator) { this.operator = operator; } + public int getNums() { return nums; } + public void setNums(int nums) { this.nums = nums; } + public Date getOperateDate() { return operateDate; } + public void setOperateDate(Date operateDate) { this.operateDate = operateDate; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + + public void printInfo() { + System.out.println("材料出入库记录:"); + System.out.println("记录编号:" + recordId); + System.out.println("材料编号:" + materialId); + System.out.println("操作人:" + operator); + System.out.println("操作数量:" + nums); + System.out.println("操作日期:" + operateDate); + System.out.println("操作类型:" + type); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/TestDI.java b/equipment-SpringProject/src/com/ssm/di/TestDI.java new file mode 100644 index 0000000..b72fe6d --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/TestDI.java @@ -0,0 +1,32 @@ +package com.ssm.di; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class TestDI { + public static void main(String[] args) { + // 1. 加载配置文件,创建Spring容器 + ApplicationContext context = new ClassPathXmlApplicationContext("bean-di-xml.xml"); + + // 2. 获取Bean并调用printInfo()输出信息 + System.out.println("===== 用户管理模块 ====="); + User user = (User) context.getBean("user"); + user.printInfo(); + + System.out.println("\n===== 材料管理模块 ====="); + Material material = (Material) context.getBean("material"); + material.printInfo(); + + System.out.println("\n===== 材料出入库管理模块 ====="); + MaterialRecord record = (MaterialRecord) context.getBean("materialRecord"); + record.printInfo(); + + System.out.println("\n===== 预约管理模块 ====="); + Appointment appointment = (Appointment) context.getBean("appointment"); + appointment.printInfo(); + + System.out.println("\n===== 实验室管理模块 ====="); + Laboratory lab = (Laboratory) context.getBean("laboratory"); + lab.printInfo(); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/User.java b/equipment-SpringProject/src/com/ssm/di/User.java new file mode 100644 index 0000000..d95c93d --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/User.java @@ -0,0 +1,34 @@ +package com.ssm.di; + +public class User { + private String username; + private String userpass; + private String truename; + private int age; + private String role; + + // 无参构造(setter注入必须要有) + public User() {} + + // Getter & Setter + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getUserpass() { return userpass; } + public void setUserpass(String userpass) { this.userpass = userpass; } + public String getTruename() { return truename; } + public void setTruename(String truename) { this.truename = truename; } + public int getAge() { return age; } + public void setAge(int age) { this.age = age; } + public String getRole() { return role; } + public void setRole(String role) { this.role = role; } + + // 按要求新增printInfo()方法 + public void printInfo() { + System.out.println("用户信息:"); + System.out.println("用户名:" + username); + System.out.println("密码:" + userpass); + System.out.println("真实姓名:" + truename); + System.out.println("年龄:" + age); + System.out.println("角色:" + role); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/Appointment.java b/equipment-SpringProject/src/com/ssm/di/annotation/Appointment.java new file mode 100644 index 0000000..3dcf191 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/annotation/Appointment.java @@ -0,0 +1,51 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import java.util.Date; + +@Component("appointment") +public class Appointment { + @Value("A001") + private String appointmentId; + + @Value("孙佳兴") + private String username; + + @Value("L001") + private String labId; + + @Value("#{new java.util.Date()}") + private Date startTime; + + @Value("#{new java.util.Date()}") + private Date endTime; + + @Value("化学实验") + private String purpose; + + public Appointment() {} + + public String getAppointmentId() { return appointmentId; } + public void setAppointmentId(String appointmentId) { this.appointmentId = appointmentId; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public Date getStartTime() { return startTime; } + public void setStartTime(Date startTime) { this.startTime = startTime; } + public Date getEndTime() { return endTime; } + public void setEndTime(Date endTime) { this.endTime = endTime; } + public String getPurpose() { return purpose; } + public void setPurpose(String purpose) { this.purpose = purpose; } + + public void printInfo() { + System.out.println("预约信息:"); + System.out.println("预约编号:" + appointmentId); + System.out.println("预约人:" + username); + System.out.println("实验室编号:" + labId); + System.out.println("开始时间:" + startTime); + System.out.println("结束时间:" + endTime); + System.out.println("用途:" + purpose); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/Course.java b/equipment-SpringProject/src/com/ssm/di/annotation/Course.java deleted file mode 100644 index 71e0723..0000000 --- a/equipment-SpringProject/src/com/ssm/di/annotation/Course.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.ssm.di.annotation; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Course { - private String courseId; - private String courseName; - private int credit; - - // 自动注入Teacher对象(核心注解) - @Autowired - private Teacher teacher; - - // 无参构造 - public Course() {} - - // Setter方法(XML给属性赋值) - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - - public void setCredit(int credit) { - this.credit = credit; - } - - // 输出方法,和之前XML版本的格式完全一致 - public void printInfo() { - System.out.println("课程编号:" + courseId); - System.out.println("课程名称:" + courseName); - System.out.println("学分:" + credit); - System.out.println("授课教师信息:工号:" + teacher.getTeacherId() + ",姓名:" + teacher.getName() + ",职称:" + teacher.getTitle()); - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/Laboratory.java b/equipment-SpringProject/src/com/ssm/di/annotation/Laboratory.java new file mode 100644 index 0000000..963f256 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/annotation/Laboratory.java @@ -0,0 +1,44 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("laboratory") +public class Laboratory { + @Value("L001") + private String labId; + + @Value("化学实验室1号") + private String labName; + + @Value("实验楼3楼") + private String location; + + @Value("30") + private int capacity; + + @Value("空闲") + private String status; + + public Laboratory() {} + + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public String getLabName() { return labName; } + public void setLabName(String labName) { this.labName = labName; } + public String getLocation() { return location; } + public void setLocation(String location) { this.location = location; } + public int getCapacity() { return capacity; } + public void setCapacity(int capacity) { this.capacity = capacity; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + public void printInfo() { + System.out.println("实验室信息:"); + System.out.println("实验室编号:" + labId); + System.out.println("实验室名称:" + labName); + System.out.println("位置:" + location); + System.out.println("容纳人数:" + capacity); + System.out.println("状态:" + status); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/Material.java b/equipment-SpringProject/src/com/ssm/di/annotation/Material.java new file mode 100644 index 0000000..d9be482 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/annotation/Material.java @@ -0,0 +1,44 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("material") +public class Material { + @Value("M001") + private String materialId; + + @Value("试管") + private String materialName; + + @Value("玻璃耗材") + private String type; + + @Value("100") + private int stock; + + @Value("个") + private String unit; + + public Material() {} + + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getMaterialName() { return materialName; } + public void setMaterialName(String materialName) { this.materialName = materialName; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + public int getStock() { return stock; } + public void setStock(int stock) { this.stock = stock; } + public String getUnit() { return unit; } + public void setUnit(String unit) { this.unit = unit; } + + public void printInfo() { + System.out.println("材料信息:"); + System.out.println("材料编号:" + materialId); + System.out.println("材料名称:" + materialName); + System.out.println("类型:" + type); + System.out.println("库存:" + stock); + System.out.println("单位:" + unit); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/MaterialRecord.java b/equipment-SpringProject/src/com/ssm/di/annotation/MaterialRecord.java new file mode 100644 index 0000000..0f59948 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/annotation/MaterialRecord.java @@ -0,0 +1,51 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import java.util.Date; + +@Component("materialRecord") +public class MaterialRecord { + @Value("R001") + private String recordId; + + @Value("M001") + private String materialId; + + @Value("喻廷屿") + private String operator; + + @Value("20") + private int nums; + + @Value("#{new java.util.Date()}") + private Date operateDate; + + @Value("入库") + private String type; + + public MaterialRecord() {} + + public String getRecordId() { return recordId; } + public void setRecordId(String recordId) { this.recordId = recordId; } + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getOperator() { return operator; } + public void setOperator(String operator) { this.operator = operator; } + public int getNums() { return nums; } + public void setNums(int nums) { this.nums = nums; } + public Date getOperateDate() { return operateDate; } + public void setOperateDate(Date operateDate) { this.operateDate = operateDate; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + + public void printInfo() { + System.out.println("材料出入库记录:"); + System.out.println("记录编号:" + recordId); + System.out.println("材料编号:" + materialId); + System.out.println("操作人:" + operator); + System.out.println("操作数量:" + nums); + System.out.println("操作日期:" + operateDate); + System.out.println("操作类型:" + type); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/Teacher.java b/equipment-SpringProject/src/com/ssm/di/annotation/Teacher.java deleted file mode 100644 index 45d7d80..0000000 --- a/equipment-SpringProject/src/com/ssm/di/annotation/Teacher.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.ssm.di.annotation; - -import org.springframework.stereotype.Component; - -// 让Spring自动扫描并创建这个Bean -@Component -public class Teacher { - private String teacherId; - private String name; - private String title; - - // 无参构造(Spring需要) - public Teacher() {} - - // Setter方法(可选,这里我们用XML给属性赋值) - public void setTeacherId(String teacherId) { - this.teacherId = teacherId; - } - - public void setName(String name) { - this.name = name; - } - - public void setTitle(String title) { - this.title = title; - } - - // Getter方法(供Course调用) - public String getTeacherId() { - return teacherId; - } - - public String getName() { - return name; - } - - public String getTitle() { - return title; - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java b/equipment-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java index 2524436..8ec6f0d 100644 --- a/equipment-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java +++ b/equipment-SpringProject/src/com/ssm/di/annotation/TestAnnotation.java @@ -1,11 +1,31 @@ package com.ssm.di.annotation; + import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestAnnotation { public static void main(String[] args) { - ApplicationContext ac = new ClassPathXmlApplicationContext("bean-di-annotation.xml"); - Course course = ac.getBean("course", Course.class); - course.printInfo(); + // 加载Spring配置 + ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); + + System.out.println("===== 用户管理模块 ====="); + User user = (User) context.getBean("user"); + user.printInfo(); + + System.out.println("\n===== 材料管理模块 ====="); + Material material = (Material) context.getBean("material"); + material.printInfo(); + + System.out.println("\n===== 材料出入库管理模块 ====="); + MaterialRecord record = (MaterialRecord) context.getBean("materialRecord"); + record.printInfo(); + + System.out.println("\n===== 预约管理模块 ====="); + Appointment appointment = (Appointment) context.getBean("appointment"); + appointment.printInfo(); + + System.out.println("\n===== 实验室管理模块 ====="); + Laboratory lab = (Laboratory) context.getBean("laboratory"); + lab.printInfo(); } } \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/annotation/User.java b/equipment-SpringProject/src/com/ssm/di/annotation/User.java new file mode 100644 index 0000000..0a717fd --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/di/annotation/User.java @@ -0,0 +1,44 @@ +package com.ssm.di.annotation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("user") +public class User { + @Value("daiyuhang") + private String username; + + @Value("123456") + private String userpass; + + @Value("代宇航") + private String truename; + + @Value("20") + private int age; + + @Value("管理员") + private String role; + + public User() {} + + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getUserpass() { return userpass; } + public void setUserpass(String userpass) { this.userpass = userpass; } + public String getTruename() { return truename; } + public void setTruename(String truename) { this.truename = truename; } + public int getAge() { return age; } + public void setAge(int age) { this.age = age; } + public String getRole() { return role; } + public void setRole(String role) { this.role = role; } + + public void printInfo() { + System.out.println("用户信息:"); + System.out.println("用户名:" + username); + System.out.println("密码:" + userpass); + System.out.println("真实姓名:" + truename); + System.out.println("年龄:" + age); + System.out.println("角色:" + role); + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/xml/Course.java b/equipment-SpringProject/src/com/ssm/di/xml/Course.java deleted file mode 100644 index a3ff754..0000000 --- a/equipment-SpringProject/src/com/ssm/di/xml/Course.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ssm.di.xml; - -public class Course { - private String courseId; // 课程编号 - private String courseName; // 课程名称 - private int credit; // 学分 - private Teacher teacher; // 授课教师 - - // Spring 必须的无参构造 - public Course() {} - - // Setter 方法(供XML注入使用) - public void setCourseId(String courseId) { - this.courseId = courseId; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - - public void setCredit(int credit) { - this.credit = credit; - } - - public void setTeacher(Teacher teacher) { - this.teacher = teacher; - } - - // 修改为和第一张截图完全一致的输出格式 - public void printInfo() { - System.out.println("课程编号:" + courseId); - System.out.println("课程名称:" + courseName); - System.out.println("学分:" + credit); - System.out.println("授课教师信息:工号:" + teacher.getTeacherId() + ",姓名:" + teacher.getName() + ",职称:" + teacher.getTitle()); - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/xml/Teacher.java b/equipment-SpringProject/src/com/ssm/di/xml/Teacher.java deleted file mode 100644 index 9756288..0000000 --- a/equipment-SpringProject/src/com/ssm/di/xml/Teacher.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ssm.di.xml; - -public class Teacher { - private String teacherId; // 工号 - private String name; // 姓名 - private String title; // 职称 - - // Spring 必须的无参构造 - public Teacher() {} - - // Setter 方法(供XML注入使用) - public void setTeacherId(String teacherId) { - this.teacherId = teacherId; - } - - public void setName(String name) { - this.name = name; - } - - public void setTitle(String title) { - this.title = title; - } - - // Getter 方法(供Course调用) - public String getTeacherId() { - return teacherId; - } - - public String getName() { - return name; - } - - public String getTitle() { - return title; - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/di/xml/TestDI.java b/equipment-SpringProject/src/com/ssm/di/xml/TestDI.java deleted file mode 100644 index b2eb32d..0000000 --- a/equipment-SpringProject/src/com/ssm/di/xml/TestDI.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.ssm.di.xml; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class TestDI { - public static void main(String[] args) { - // 1. 加载Spring配置文件 - ApplicationContext context = new ClassPathXmlApplicationContext("bean-di-xml.xml"); - - // 2. 获取Course对象 - Course course = context.getBean("course", Course.class); - - // 3. 调用方法,输出信息 - course.printInfo(); - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/first/TestFirst.java b/equipment-SpringProject/src/com/ssm/first/TestFirst.java deleted file mode 100644 index ad7ff4a..0000000 --- a/equipment-SpringProject/src/com/ssm/first/TestFirst.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ssm.first; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class TestFirst { -public static void main(String[] args) { - ApplicationContext ac = new ClassPathXmlApplicationContext("bean-first.xml"); - System.out.println("Hello Spring!"); - System.out.println("Hello Spring!"); - System.out.println("Hello Spring!"); - System.out.println("Hello Spring!"); - System.out.println("Hello Spring!"); - -} -} diff --git a/equipment-SpringProject/src/com/ssm/ioc/Appointment.java b/equipment-SpringProject/src/com/ssm/ioc/Appointment.java new file mode 100644 index 0000000..f50b3e8 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/ioc/Appointment.java @@ -0,0 +1,40 @@ +package com.ssm.ioc; + +import java.util.Date; + +public class Appointment { + private String appointmentId; + private String username; + private String labId; + private Date startTime; + private Date endTime; + private String purpose; + + public Appointment() { + } + + public String getAppointmentId() { return appointmentId; } + public void setAppointmentId(String appointmentId) { this.appointmentId = appointmentId; } + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public Date getStartTime() { return startTime; } + public void setStartTime(Date startTime) { this.startTime = startTime; } + public Date getEndTime() { return endTime; } + public void setEndTime(Date endTime) { this.endTime = endTime; } + public String getPurpose() { return purpose; } + public void setPurpose(String purpose) { this.purpose = purpose; } + + @Override + public String toString() { + return "Appointment{" + + "appointmentId='" + appointmentId + '\'' + + ", username='" + username + '\'' + + ", labId='" + labId + '\'' + + ", startTime=" + startTime + + ", endTime=" + endTime + + ", purpose='" + purpose + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/Goods.java b/equipment-SpringProject/src/com/ssm/ioc/Goods.java deleted file mode 100644 index c84c8e0..0000000 --- a/equipment-SpringProject/src/com/ssm/ioc/Goods.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.ssm.ioc; - -/** - * 商品实体类 - */ -public class Goods { - private String goodsId; // 商品ID - private String goodsName; // 商品名 - private double price; // 价格 - private String brand; // 品牌 - private int stock; // 库存 - - public Goods() {} - - public String getGoodsId() { - return goodsId; - } - - public void setGoodsId(String goodsId) { - this.goodsId = goodsId; - } - - public String getGoodsName() { - return goodsName; - } - - public void setGoodsName(String goodsName) { - this.goodsName = goodsName; - } - - public double getPrice() { - return price; - } - - public void setPrice(double price) { - this.price = price; - } - - public String getBrand() { - return brand; - } - - public void setBrand(String brand) { - this.brand = brand; - } - - public int getStock() { - return stock; - } - - public void setStock(int stock) { - this.stock = stock; - } - - @Override - public String toString() { - return "Goods{" + - "goodsId='" + goodsId + '\'' + - ", goodsName='" + goodsName + '\'' + - ", price=" + price + - ", brand='" + brand + '\'' + - ", stock=" + stock + - '}'; - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/Laboratory.java b/equipment-SpringProject/src/com/ssm/ioc/Laboratory.java new file mode 100644 index 0000000..1ae7718 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/ioc/Laboratory.java @@ -0,0 +1,34 @@ +package com.ssm.ioc; + +public class Laboratory { + private String labId; + private String labName; + private String location; + private int capacity; + private String status; + + public Laboratory() { + } + + public String getLabId() { return labId; } + public void setLabId(String labId) { this.labId = labId; } + public String getLabName() { return labName; } + public void setLabName(String labName) { this.labName = labName; } + public String getLocation() { return location; } + public void setLocation(String location) { this.location = location; } + public int getCapacity() { return capacity; } + public void setCapacity(int capacity) { this.capacity = capacity; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + @Override + public String toString() { + return "Laboratory{" + + "labId='" + labId + '\'' + + ", labName='" + labName + '\'' + + ", location='" + location + '\'' + + ", capacity=" + capacity + + ", status='" + status + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/Material.java b/equipment-SpringProject/src/com/ssm/ioc/Material.java new file mode 100644 index 0000000..932b065 --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/ioc/Material.java @@ -0,0 +1,34 @@ +package com.ssm.ioc; + +public class Material { + private String materialId; + private String materialName; + private String type; + private int stock; + private String unit; + + public Material() { + } + + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getMaterialName() { return materialName; } + public void setMaterialName(String materialName) { this.materialName = materialName; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + public int getStock() { return stock; } + public void setStock(int stock) { this.stock = stock; } + public String getUnit() { return unit; } + public void setUnit(String unit) { this.unit = unit; } + + @Override + public String toString() { + return "Material{" + + "materialId='" + materialId + '\'' + + ", materialName='" + materialName + '\'' + + ", type='" + type + '\'' + + ", stock=" + stock + + ", unit='" + unit + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/MaterialRecord.java b/equipment-SpringProject/src/com/ssm/ioc/MaterialRecord.java new file mode 100644 index 0000000..bfc7ecd --- /dev/null +++ b/equipment-SpringProject/src/com/ssm/ioc/MaterialRecord.java @@ -0,0 +1,40 @@ +package com.ssm.ioc; + +import java.util.Date; + +public class MaterialRecord { + private String recordId; + private String materialId; + private String operator; + private int nums; + private Date operateDate; + private String type; + + public MaterialRecord() { + } + + public String getRecordId() { return recordId; } + public void setRecordId(String recordId) { this.recordId = recordId; } + public String getMaterialId() { return materialId; } + public void setMaterialId(String materialId) { this.materialId = materialId; } + public String getOperator() { return operator; } + public void setOperator(String operator) { this.operator = operator; } + public int getNums() { return nums; } + public void setNums(int nums) { this.nums = nums; } + public Date getOperateDate() { return operateDate; } + public void setOperateDate(Date operateDate) { this.operateDate = operateDate; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + + @Override + public String toString() { + return "MaterialRecord{" + + "recordId='" + recordId + '\'' + + ", materialId='" + materialId + '\'' + + ", operator='" + operator + '\'' + + ", nums=" + nums + + ", operateDate=" + operateDate + + ", type='" + type + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/Order.java b/equipment-SpringProject/src/com/ssm/ioc/Order.java deleted file mode 100644 index c6dabea..0000000 --- a/equipment-SpringProject/src/com/ssm/ioc/Order.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.ssm.ioc; - -import java.util.Date; - -/** - * 订单实体类 - */ -public class Order { - private String id; // 订单编号 - private String username; // 下单人 - private String goodsname; // 商品名称 - private int nums; // 购买数量 - private Date date; // 下单日期 - - public Order() {} - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getGoodsname() { - return goodsname; - } - - public void setGoodsname(String goodsname) { - this.goodsname = goodsname; - } - - public int getNums() { - return nums; - } - - public void setNums(int nums) { - this.nums = nums; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - @Override - public String toString() { - return "Order{" + - "id='" + id + '\'' + - ", username='" + username + '\'' + - ", goodsname='" + goodsname + '\'' + - ", nums=" + nums + - ", date=" + date + - '}'; - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/Teacher.java b/equipment-SpringProject/src/com/ssm/ioc/Teacher.java deleted file mode 100644 index 562bf91..0000000 --- a/equipment-SpringProject/src/com/ssm/ioc/Teacher.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.ssm.ioc; - -/** - * 教师实体类 - */ -public class Teacher { - private String teacherId; // 工号 - private String name; // 姓名 - private String course; // 授课课程 - private String department; // 部门 - private int workAge; // 教龄 - - public Teacher() {} - - public String getTeacherId() { - return teacherId; - } - - public void setTeacherId(String teacherId) { - this.teacherId = teacherId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCourse() { - return course; - } - - public void setCourse(String course) { - this.course = course; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public int getWorkAge() { - return workAge; - } - - public void setWorkAge(int workAge) { - this.workAge = workAge; - } - - @Override - public String toString() { - return "Teacher{" + - "teacherId='" + teacherId + '\'' + - ", name='" + name + '\'' + - ", course='" + course + '\'' + - ", department='" + department + '\'' + - ", workAge=" + workAge + - '}'; - } -} \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/TestIoc.java b/equipment-SpringProject/src/com/ssm/ioc/TestIoc.java index 3bfdb48..7a9be58 100644 --- a/equipment-SpringProject/src/com/ssm/ioc/TestIoc.java +++ b/equipment-SpringProject/src/com/ssm/ioc/TestIoc.java @@ -3,31 +3,24 @@ package com.ssm.ioc; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -/** - * IOC 测试类:获取所有Bean并输出对象信息 - */ public class TestIoc { public static void main(String[] args) { - // 1. 加载Spring配置文件 - ApplicationContext context = new ClassPathXmlApplicationContext("bean-ioc.xml"); + // 配置文件在 src 根目录,直接写文件名 + ApplicationContext context = new ClassPathXmlApplicationContext("bean-di-xml.xml"); - // 2. 获取Bean - User user = (User) context.getBean("user"); - Order order = (Order) context.getBean("order"); - Goods goods = (Goods) context.getBean("goods"); - Teacher teacher = (Teacher) context.getBean("teacher"); + System.out.println("===== 用户管理模块 ====="); + System.out.println(context.getBean("user")); - // 3. 输出所有对象信息 - System.out.println("===== 用户信息 ====="); - System.out.println(user); + System.out.println("\n===== 材料管理模块 ====="); + System.out.println(context.getBean("material")); - System.out.println("\n===== 订单信息 ====="); - System.out.println(order); + System.out.println("\n===== 材料出入库管理模块 ====="); + System.out.println(context.getBean("materialRecord")); - System.out.println("\n===== 商品信息 ====="); - System.out.println(goods); + System.out.println("\n===== 预约管理模块 ====="); + System.out.println(context.getBean("appointment")); - System.out.println("\n===== 教师信息 ====="); - System.out.println(teacher); + System.out.println("\n===== 实验室管理模块 ====="); + System.out.println(context.getBean("laboratory")); } } \ No newline at end of file diff --git a/equipment-SpringProject/src/com/ssm/ioc/User.java b/equipment-SpringProject/src/com/ssm/ioc/User.java index eff2c52..9a4e266 100644 --- a/equipment-SpringProject/src/com/ssm/ioc/User.java +++ b/equipment-SpringProject/src/com/ssm/ioc/User.java @@ -1,61 +1,26 @@ package com.ssm.ioc; -/** - * 用户实体类 - */ public class User { - // 属性 ≥4个 - private String username; // 用户名 - private String userpass; // 密码 - private String truename; // 真实姓名 - private int age; // 年龄 - private String email; // 邮箱(第5个) + private String username; + private String userpass; + private String truename; + private int age; + private String role; + + public User() { + } + + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } + public String getUserpass() { return userpass; } + public void setUserpass(String userpass) { this.userpass = userpass; } + public String getTruename() { return truename; } + public void setTruename(String truename) { this.truename = truename; } + public int getAge() { return age; } + public void setAge(int age) { this.age = age; } + public String getRole() { return role; } + public void setRole(String role) { this.role = role; } - // 无参构造(Spring必须) - public User() {} - - // getter & setter - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getUserpass() { - return userpass; - } - - public void setUserpass(String userpass) { - this.userpass = userpass; - } - - public String getTruename() { - return truename; - } - - public void setTruename(String truename) { - this.truename = truename; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - // 输出对象信息 @Override public String toString() { return "User{" + @@ -63,7 +28,7 @@ public class User { ", userpass='" + userpass + '\'' + ", truename='" + truename + '\'' + ", age=" + age + - ", email='" + email + '\'' + + ", role='" + role + '\'' + '}'; } } \ No newline at end of file diff --git a/equipment-SpringProject/src/libs/jsp-api.jar b/equipment-SpringProject/src/libs/jsp-api.jar new file mode 100644 index 0000000..d405b74 Binary files /dev/null and b/equipment-SpringProject/src/libs/jsp-api.jar differ diff --git a/equipment-SpringProject/src/libs/spring-web-5.1.6.RELEASE.jar b/equipment-SpringProject/src/libs/spring-web-5.1.6.RELEASE.jar new file mode 100644 index 0000000..1e346d9 Binary files /dev/null and b/equipment-SpringProject/src/libs/spring-web-5.1.6.RELEASE.jar differ diff --git a/equipment-SpringProject/src/libs/spring-webmvc-5.1.6.RELEASE.jar b/equipment-SpringProject/src/libs/spring-webmvc-5.1.6.RELEASE.jar new file mode 100644 index 0000000..c6bec3a Binary files /dev/null and b/equipment-SpringProject/src/libs/spring-webmvc-5.1.6.RELEASE.jar differ