From 6fc8e45bacb2e5cb65ed494e97771e9bdd53a54c Mon Sep 17 00:00:00 2001 From: qinyingjie Date: Sat, 12 Nov 2022 20:21:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B5=8B=E8=AF=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/kwan/spring5/Course.java | 27 ++++++++ src/main/java/com/kwan/spring5/Emp.java | 4 ++ src/main/java/com/kwan/spring5/Stu.java | 67 +++++++++++++++++++ src/main/resources/spring6.xml | 23 +++++++ src/main/resources/spring7.xml | 23 +++++++ src/main/resources/spring8.xml | 42 ++++++++++++ src/main/resources/spring9.xml | 55 +++++++++++++++ ...ptTest.java => Spring_06_DeptTest_01.java} | 2 +- src/test/java/Spring_06_DeptTest_02.java | 22 ++++++ src/test/java/Spring_06_DeptTest_03.java | 22 ++++++ src/test/java/Spring_07_StuTest_01.java | 22 ++++++ src/test/java/Spring_07_StuTest_02.java | 22 ++++++ 12 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/kwan/spring5/Course.java create mode 100644 src/main/java/com/kwan/spring5/Stu.java create mode 100644 src/main/resources/spring6.xml create mode 100644 src/main/resources/spring7.xml create mode 100644 src/main/resources/spring8.xml create mode 100644 src/main/resources/spring9.xml rename src/test/java/{Spring_06_DeptTest.java => Spring_06_DeptTest_01.java} (93%) create mode 100644 src/test/java/Spring_06_DeptTest_02.java create mode 100644 src/test/java/Spring_06_DeptTest_03.java create mode 100644 src/test/java/Spring_07_StuTest_01.java create mode 100644 src/test/java/Spring_07_StuTest_02.java diff --git a/src/main/java/com/kwan/spring5/Course.java b/src/main/java/com/kwan/spring5/Course.java new file mode 100644 index 0000000..608f471 --- /dev/null +++ b/src/main/java/com/kwan/spring5/Course.java @@ -0,0 +1,27 @@ +package com.kwan.spring5; + +/** + * 课程 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 20:17 + */ +public class Course { + + /** + * 课程名称 + */ + private String cname; + + public void setCname(String cname) { + this.cname = cname; + } + + @Override + public String toString() { + return "Course{" + + "cname='" + cname + '\'' + + '}'; + } +} diff --git a/src/main/java/com/kwan/spring5/Emp.java b/src/main/java/com/kwan/spring5/Emp.java index 8ee7f9e..b1b9ecf 100644 --- a/src/main/java/com/kwan/spring5/Emp.java +++ b/src/main/java/com/kwan/spring5/Emp.java @@ -33,6 +33,10 @@ public class Emp { this.gender = gender; } + public Dept getDept() { + return dept; + } + @Override public String toString() { return "Emp{" + diff --git a/src/main/java/com/kwan/spring5/Stu.java b/src/main/java/com/kwan/spring5/Stu.java new file mode 100644 index 0000000..ae6f69d --- /dev/null +++ b/src/main/java/com/kwan/spring5/Stu.java @@ -0,0 +1,67 @@ +package com.kwan.spring5; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 创建类,定义数组、list、map、set 类型属性,生成对应 set 方法 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 20:14 + */ +public class Stu { + /** + * 数组类型属性 + */ + private String[] courses; + /** + * list集合类型属性 + */ + private List list; + /** + * map集合类型属性 + */ + private Map maps; + /** + * set集合类型属性 + */ + private Set sets; + /** + * 学生所学多门课程 + */ + private List courseList;//创建集合 + + public void setSets(Set sets) { + this.sets = sets; + } + + public void setCourses(String[] courses) { + this.courses = courses; + } + + public void setList(List list) { + this.list = list; + } + + public void setMaps(Map maps) { + this.maps = maps; + } + + public void setCourseList(List courseList) { + this.courseList = courseList; + } + + @Override + public String toString() { + return "Stu{" + + "courses=" + Arrays.toString(courses) + + ", list=" + list + + ", maps=" + maps + + ", sets=" + sets + + ", courseList=" + courseList + + '}'; + } +} \ No newline at end of file diff --git a/src/main/resources/spring6.xml b/src/main/resources/spring6.xml new file mode 100644 index 0000000..57f26c9 --- /dev/null +++ b/src/main/resources/spring6.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/spring7.xml b/src/main/resources/spring7.xml new file mode 100644 index 0000000..04a628e --- /dev/null +++ b/src/main/resources/spring7.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/spring8.xml b/src/main/resources/spring8.xml new file mode 100644 index 0000000..7b5e605 --- /dev/null +++ b/src/main/resources/spring8.xml @@ -0,0 +1,42 @@ + + + + + + + + + + java课程 + 数据库课程 + + + + + + 张三 + 小三 + + + + + + + + + + + + + MySQL + Redis + + + + \ No newline at end of file diff --git a/src/main/resources/spring9.xml b/src/main/resources/spring9.xml new file mode 100644 index 0000000..8cd835d --- /dev/null +++ b/src/main/resources/spring9.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + java课程 + 数据库课程 + + + + + + 张三 + 小三 + + + + + + + + + + + + + MySQL + Redis + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/Spring_06_DeptTest.java b/src/test/java/Spring_06_DeptTest_01.java similarity index 93% rename from src/test/java/Spring_06_DeptTest.java rename to src/test/java/Spring_06_DeptTest_01.java index 8c8683f..75a65d6 100644 --- a/src/test/java/Spring_06_DeptTest.java +++ b/src/test/java/Spring_06_DeptTest_01.java @@ -10,7 +10,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * @version : 2.2.0 * @date : 2022/11/12 18:43 */ -public class Spring_06_DeptTest { +public class Spring_06_DeptTest_01 { @Test public void test1() { diff --git a/src/test/java/Spring_06_DeptTest_02.java b/src/test/java/Spring_06_DeptTest_02.java new file mode 100644 index 0000000..0021576 --- /dev/null +++ b/src/test/java/Spring_06_DeptTest_02.java @@ -0,0 +1,22 @@ +import com.kwan.spring5.Emp; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * 测试ioc注入 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 18:43 + */ +public class Spring_06_DeptTest_02 { + + @Test + public void test1() { + ApplicationContext ctx = + new ClassPathXmlApplicationContext("spring6.xml"); + Emp emp = (Emp) ctx.getBean("emp"); + System.out.println(emp); + } +} diff --git a/src/test/java/Spring_06_DeptTest_03.java b/src/test/java/Spring_06_DeptTest_03.java new file mode 100644 index 0000000..bff445b --- /dev/null +++ b/src/test/java/Spring_06_DeptTest_03.java @@ -0,0 +1,22 @@ +import com.kwan.spring5.Emp; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * 测试ioc注入 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 18:43 + */ +public class Spring_06_DeptTest_03 { + + @Test + public void test1() { + ApplicationContext ctx = + new ClassPathXmlApplicationContext("spring7.xml"); + Emp emp = (Emp) ctx.getBean("emp"); + System.out.println(emp); + } +} diff --git a/src/test/java/Spring_07_StuTest_01.java b/src/test/java/Spring_07_StuTest_01.java new file mode 100644 index 0000000..e186c0e --- /dev/null +++ b/src/test/java/Spring_07_StuTest_01.java @@ -0,0 +1,22 @@ +import com.kwan.spring5.Stu; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * 测试ioc注入 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 18:43 + */ +public class Spring_07_StuTest_01 { + + @Test + public void test1() { + ApplicationContext ctx = + new ClassPathXmlApplicationContext("spring8.xml"); + Stu stu = (Stu) ctx.getBean("stu"); + System.out.println(stu); + } +} diff --git a/src/test/java/Spring_07_StuTest_02.java b/src/test/java/Spring_07_StuTest_02.java new file mode 100644 index 0000000..1be840f --- /dev/null +++ b/src/test/java/Spring_07_StuTest_02.java @@ -0,0 +1,22 @@ +import com.kwan.spring5.Stu; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * 测试ioc注入 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2022/11/12 18:43 + */ +public class Spring_07_StuTest_02 { + + @Test + public void test1() { + ApplicationContext ctx = + new ClassPathXmlApplicationContext("spring9.xml"); + Stu stu = (Stu) ctx.getBean("stu"); + System.out.println(stu); + } +} -- GitLab