diff --git a/flowers-SpringProject/src/bean-ioc.xml b/flowers-SpringProject/src/bean-ioc.xml new file mode 100644 index 0000000..259ddf4 --- /dev/null +++ b/flowers-SpringProject/src/bean-ioc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/flowers-SpringProject/src/com/ssm/ioc/Order.java b/flowers-SpringProject/src/com/ssm/ioc/Order.java new file mode 100644 index 0000000..067597e --- /dev/null +++ b/flowers-SpringProject/src/com/ssm/ioc/Order.java @@ -0,0 +1,56 @@ +package com.ssm.ioc; + +import java.util.Date; + +/** + * 订单管理模块实体类 + * 符合作业要求:属性≥4个,命名规范,与用户、花卉关联 + */ +public class Order { + // 订单编号 + private String id; + // 下单人用户名(关联用户) + private String username; + // 花卉名称(关联花卉) + private String flowerName; + // 购买数量 + private Integer nums; + // 下单日期 + private Date orderDate; + // 订单总金额 + private Double totalPrice; + + // 【必须】无参构造器(Spring IoC强制要求) + public Order() {} + + // 【必须】完整Getter/Setter + 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 getFlowerName() { return flowerName; } + public void setFlowerName(String flowerName) { this.flowerName = flowerName; } + + public Integer getNums() { return nums; } + public void setNums(Integer nums) { this.nums = nums; } + + public Date getOrderDate() { return orderDate; } + public void setOrderDate(Date orderDate) { this.orderDate = orderDate; } + + public Double getTotalPrice() { return totalPrice; } + public void setTotalPrice(Double totalPrice) { this.totalPrice = totalPrice; } + + @Override + public String toString() { + return "Order{" + + "id='" + id + '\'' + + ", username='" + username + '\'' + + ", flowerName='" + flowerName + '\'' + + ", nums=" + nums + + ", orderDate=" + orderDate + + ", totalPrice=" + totalPrice + + '}'; + } +} \ No newline at end of file diff --git a/flowers-SpringProject/src/com/ssm/ioc/TestIoc.java b/flowers-SpringProject/src/com/ssm/ioc/TestIoc.java new file mode 100644 index 0000000..ebc55cc --- /dev/null +++ b/flowers-SpringProject/src/com/ssm/ioc/TestIoc.java @@ -0,0 +1,26 @@ +package com.ssm.ioc; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * Spring IoC测试类 + * 符合作业要求:包含整个小组所有模块的对象信息输出 + */ +public class TestIoc { + public static void main(String[] args) { + // 1. 加载Spring配置文件 + ApplicationContext context = new ClassPathXmlApplicationContext("bean-ioc.xml"); + + // ========== 5. 订单管理模块 ========== + System.out.println("===== 5. 订单管理模块信息 ====="); + Order order = context.getBean("order", Order.class); + System.out.println("订单编号:" + order.getId()); + System.out.println("下单人:" + order.getUsername()); + System.out.println("花卉名称:" + order.getFlowerName()); + System.out.println("购买数量:" + order.getNums()); + System.out.println("下单日期:" + order.getOrderDate()); + System.out.println("订单总金额:" + order.getTotalPrice()); + System.out.println("完整订单信息:" + order + "\n"); + } +} \ No newline at end of file