完成Notice实体模块的注解式Bean配置

main
齐辉 5 days ago
parent adce50f0c0
commit a577324a3b

@ -0,0 +1,105 @@
package com.ssm.annotation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("notice")
public class Notice {
@Value("1")
// 通知ID主键
private Integer noticeId;
@Value("1001")
// 关联用户ID与用户模块关联
private Integer userId;
@Value("月度预算提醒")
// 通知标题
private String noticeTitle;
@Value("您本月餐饮预算已使用80%,请注意控制支出")
// 通知内容
private String noticeContent;
@Value("预算提醒")
// 通知类型(如:预算提醒、交易提醒、系统通知)
private String noticeType;
@Value("0")
// 通知状态0-未读1-已读)
private Integer noticeStatus;
@Value("2026-4-10 09:00:00")
// 通知创建时间
private String createTime;
public Notice(){}
public Notice(Integer noticeId, Integer userId, String noticeTitle, String noticeContent, String noticeType, Integer noticeStatus, String createTime) {
this.noticeId = noticeId;
this.userId = userId;
this.noticeTitle = noticeTitle;
this.noticeContent = noticeContent;
this.noticeType = noticeType;
this.noticeStatus = noticeStatus;
this.createTime = createTime;
}
public Integer getNoticeId() {
return noticeId;
}
public void setNoticeId(Integer noticeId) {
this.noticeId = noticeId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getNoticeTitle() {
return noticeTitle;
}
public void setNoticeTitle(String noticeTitle) {
this.noticeTitle = noticeTitle;
}
public String getNoticeContent() {
return noticeContent;
}
public void setNoticeContent(String noticeContent) {
this.noticeContent = noticeContent;
}
public String getNoticeType() {
return noticeType;
}
public void setNoticeType(String noticeType) {
this.noticeType = noticeType;
}
public Integer getNoticeStatus() {
return noticeStatus;
}
public void setNoticeStatus(Integer noticeStatus) {
this.noticeStatus = noticeStatus;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String toString(){
return "通知ID" + noticeId + "\n"
+ "关联用户ID" + userId + "\n"
+ "通知标题:" + noticeTitle + "\n"
+ "通知内容:" + noticeContent + "\n"
+ "通知类型:" + noticeType + "\n"
+ "通知状态:" + noticeStatus + "\n"
+ "创建时间:" + createTime + "\n";
}
}

@ -1,5 +1,6 @@
package com.ssm.annotation;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@ -12,6 +13,8 @@ public static void main(String[] args) {
Budget budget = (Budget) applicationContext.getBean("budget");
//输出Budget实例的信息
System.out.println(budget.toString());
// 获取Notice Bean
Notice notice = (Notice) applicationContext.getBean("notice");
System.out.println(notice.toString());
}
}

Loading…
Cancel
Save