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

main
郝辰余 3 weeks ago
parent a577324a3b
commit bf9cb75d7d

@ -0,0 +1,87 @@
package com.ssm.annotation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Dict {
// 1. 私有属性满足≥4个要求
// 字典ID
@Value("1")
private Integer dictId;
// 字典类型
@Value("income_type")
private String dictType;
// 字典编码
@Value("1")
private String dictCode;
// 字典名称
@Value("工资收入")
private String dictName;
// 排序序号
@Value("1")
private Integer dictSort;
// 是否有效Y/N
@Value("Y")
private String isValid;
public Integer getDictId() {
return dictId;
}
public void setDictId(Integer dictId) {
this.dictId = dictId;
}
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType;
}
public String getDictCode() {
return dictCode;
}
public void setDictCode(String dictCode) {
this.dictCode = dictCode;
}
public String getDictName() {
return dictName;
}
public void setDictName(String dictName) {
this.dictName = dictName;
}
public Integer getDictSort() {
return dictSort;
}
public void setDictSort(Integer dictSort) {
this.dictSort = dictSort;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public String toString(){
return
"数据字典1"+"\n"+
"字典ID" + dictId + "\n"
+ "字典类型:" + dictType +"\n"
+ "字典编码:" + dictCode + "\n"
+ "字典名称:" + dictName + "\n"
+ "排序序号:" + dictSort + "\n"
+ "是否有效(Y/N)" + isValid;
}
}

@ -16,5 +16,9 @@ public static void main(String[] args) {
// 获取Notice Bean
Notice notice = (Notice) applicationContext.getBean("notice");
System.out.println(notice.toString());
//获得Dict对象
Dict dict = (Dict) applicationContext.getBean("dict");
//输出Dict实例的信息
System.out.println(dict.toString());
}
}

Loading…
Cancel
Save