From 6ec00f4f82a0bb1fadb29db5911170af1cb54792 Mon Sep 17 00:00:00 2001 From: Dell User <754470311@qq.com> Date: Fri, 10 Apr 2026 18:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flowers-SpringProject/src/bean-ioc.xml | 9 ++ .../src/com/ssm/ioc/Announcement.java | 101 ++++++++++++++++++ .../src/com/ssm/ioc/Testioc.java | 4 + .../flowers-SpringProject/bean-ioc.xml | 9 ++ .../com/ssm/ioc/Testioc.class | Bin 1709 -> 1866 bytes 5 files changed, 123 insertions(+) create mode 100644 flowers-SpringProject/src/com/ssm/ioc/Announcement.java diff --git a/flowers-SpringProject/src/bean-ioc.xml b/flowers-SpringProject/src/bean-ioc.xml index db593c8..b86fcd1 100644 --- a/flowers-SpringProject/src/bean-ioc.xml +++ b/flowers-SpringProject/src/bean-ioc.xml @@ -29,5 +29,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/flowers-SpringProject/src/com/ssm/ioc/Announcement.java b/flowers-SpringProject/src/com/ssm/ioc/Announcement.java new file mode 100644 index 0000000..793e9c5 --- /dev/null +++ b/flowers-SpringProject/src/com/ssm/ioc/Announcement.java @@ -0,0 +1,101 @@ +package com.ssm.ioc; + +public class Announcement { + // 公告ID(主键) + private Integer id; + // 公告标题 + private String title; + // 公告内容 + private String content; + // 发布人 + private String publisher; + // 发布时间 + private String publishTime; + // 公告状态(0:未发布 1:已发布) + private Integer status; + + // 无参构造(Spring IoC 必须) + public Announcement() { + } + + // 全参构造(可选,方便初始化) + public Announcement(Integer id, String title, String content, String publisher, String publishTime, Integer status) { + this.id = id; + this.title = title; + this.content = content; + this.publisher = publisher; + this.publishTime = publishTime; + this.status = status; + } + + // Getter & Setter(Spring 依赖注入必须) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getPublishTime() { + return publishTime; + } + + public void setPublishTime(String publishTime) { + this.publishTime = publishTime; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public void printInfo() { + System.out.println("===== 公告信息 ====="); + System.out.println("公告ID:" + id); + System.out.println("公告标题:" + title); + System.out.println("公告内容:" + content); + System.out.println("发布人:" + publisher); + System.out.println("发布时间:" + publishTime); + System.out.println("公告状态:" + (status == 1 ? "已发布" : "未发布")); + } + + @Override + public String toString() { + return "Announcement{" + + "id=" + id + + ", title='" + title + '\'' + + ", content='" + content + '\'' + + ", publisher='" + publisher + '\'' + + ", publishTime='" + publishTime + '\'' + + ", status=" + status + + '}'; + } +} \ 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 index a497ff3..8944ec1 100644 --- a/flowers-SpringProject/src/com/ssm/ioc/Testioc.java +++ b/flowers-SpringProject/src/com/ssm/ioc/Testioc.java @@ -22,6 +22,10 @@ public class Testioc { Message message = context.getBean("message", Message.class); System.out.println("留言信息:" + message); + Announcement announcement = context.getBean("announcement", Announcement.class); + //直接打印对象 + System.out.println("公告信息:" + announcement); + } diff --git a/out/production/flowers-SpringProject/bean-ioc.xml b/out/production/flowers-SpringProject/bean-ioc.xml index db593c8..b86fcd1 100644 --- a/out/production/flowers-SpringProject/bean-ioc.xml +++ b/out/production/flowers-SpringProject/bean-ioc.xml @@ -29,5 +29,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/out/production/flowers-SpringProject/com/ssm/ioc/Testioc.class b/out/production/flowers-SpringProject/com/ssm/ioc/Testioc.class index 7099da5b12e4ed1a14de4699d58a9f66e13cee67..ea017eba0f73aa66275415a45340a1636fa3ff3a 100644 GIT binary patch delta 589 zcmYk4-*1ai7{@>7t+(g&^=_3;mer4rjxxn-YMqUZ&CIVc!))_wTdNq_Cdw_5;KGGO z-o%Bg{Q*RZRE9LJm$>&2G|SvbT)7hG)J@OD^YixW>7NZ5TaLc#Q0%{AV*C!;&6=PiW8=CQgO=oQN?NF<p* zqDyjCF|J5S&MD3-x+NEsVnT9JGFg6@7M<=~p-_BK$ma67!hONI(QGmAl}dSUzL@m} z8+v|Ov%MCLAg0(h!lZ0M zJ$+Mq`TRpmU`4cS(zi9wLZH{yc8edjTT@$gEvPeN6WY4<*k&8sbrzzN9R>^H1p$pg zSpJm#Bb|(FjKmg^0lpFIv)`k>5Sspk6KSvDM(ql%6`CuA%bLc*$fRlV`-92JD9fxD zf>>Q};6Euzc4~~nA9k@@OSbV7k3D+!6?f@kua>VeOiKThRfd6X&1h?6PhDaEKjLI? A%m4rY delta 447 zcmXAlNl#Qk6otQfkM64Xc#R7pG0=hob7PBiw@fO^AUH6z4Tv@%(;wg$7!zXLkdRcu zf)HTmN=-*L64MDg!p5+}AMiq0`45a$&sv;w@44sP+|+5+m&E(izei;t%bHI;SxHWD z-^Za_(IM%nq?bOAejZ33`gmj&k1P-P#CdG1Cq9D=DTb{wqIha~R551xnRPr@q$MvD zFBP4Vam9pWQZgkQz92X~|5$EU)#3lPb*d zCg3f_fO(3Ng@8r!0x$gb@#5gapPxGc?q zvl1}Js&?GGPPvKio9>yYzHUCkJ_mt0%ivAD9;?aRGFsep7H=C2qB=$+O{Vi`rp0