Merge remote-tracking branch 'origin/main'

# Conflicts:
#	ffms-SpringProject/src/com/ssm/ioc/TestIoc.java
main
齐辉 1 week ago
commit 6fc235ca60

@ -3,4 +3,24 @@
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 预算管理模块Budget实体Bean配置 -->
<bean id="budget" class="com.ssm.ioc.Budget">
<property name="budgetId" value="0001"/>
<property name="category" value="餐饮预算"/>
<property name="amount" value="5000.00"/>
<property name="period" value="月度"/>
<property name="startDate" value="2025-04-01"/>
<property name="remark" value="无"/>
</bean>
<!-- 数据字典Dict Bean配置 -->
<bean id="dict" class="com.ssm.ioc.Dict">
<!-- 给属性注入值 -->
<property name="dictId" value="1"/>
<property name="dictType" value="income_type"/>
<property name="dictCode" value="1"/>
<property name="dictName" value="工资收入"/>
<property name="dictSort" value="1"/>
<property name="isValid" value="Y"/>
</bean>
</beans>

@ -0,0 +1,76 @@
package com.ssm.ioc;
import java.math.BigDecimal;
public class Budget {
//预算编号
private Integer budgetId;
//预算分类
private String category;
//预算金额
private BigDecimal amount;
//预算周期
private String period;
//预算生效日期
private String startDate;
//预算备注
private String remark;
public Integer getBudgetId() {
return budgetId;
}
public void setBudgetId(Integer budgetId) {
this.budgetId = budgetId;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getPeriod() {
return period;
}
public void setPeriod(String period) {
this.period = period;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
//自定义方法
public void printBudgetInfo(){
System.out.println("预算编号:" + budgetId);
System.out.println("预算分类:" + category);
System.out.println("预算金额:" + amount);
System.out.println("预算周期:" + period);
System.out.println("生效日期:" + startDate);
System.out.println("备注:" + remark);
}
}

@ -0,0 +1,73 @@
package com.ssm.ioc;
/**
*
*/
public class Dict {
// 1. 私有属性满足≥4个要求
private Integer dictId; // 字典ID
private String dictType; // 字典类型
private String dictCode; // 字典编码
private String dictName; // 字典名称
private Integer dictSort; // 排序序号
private String isValid; // 是否有效Y/N
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 void printDictInfo(){
System.out.println("数据字典1");
System.out.println("字典ID" + dictId);
System.out.println("字典类型:" + dictType);
System.out.println("字典编码:" + dictCode);
System.out.println("字典名称:" + dictName);
System.out.println("排序序号:" + dictSort);
System.out.println("是否有效Y/N" + isValid);
}
}

@ -5,9 +5,20 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestIoc {
public static void main(String[] args) {
//1.初始化Spring容器加载配置文件
ApplicationContext ac=new ClassPathXmlApplicationContext("bean-ioc.xml");
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("bean-ioc.xml");
//从Ioc容器中获得Budget对象
Budget budget = (Budget) applicationContext.getBean("budget");
budget.printBudgetInfo();
//2.从ioc容器中获取Dict对象
Dict dict = (Dict) applicationContext.getBean("dict");
dict.printDictInfo();
// 2. 获取Notice Bean
Notice notice=(Notice) ac.getBean("notice");
Notice notice=(Notice) applicationContext.getBean("notice");
notice.printNoticeInfo();
}
}

@ -1,12 +1,15 @@
package com.ssm.ioc;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestNew {
public static void main(String[] args) {
//1.初始化Spring容器加载配置文件
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("bean-first.xml");
System.out.println("Hello Spring! ");
//通过new的方式实例化Budget对象
Budget budget = new Budget();
System.out.println(budget);
//通过new的方式实例化Dict对象
Dict dict=new Dict();
System.out.println(dict);
}
}

Loading…
Cancel
Save