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 0000000000000000000000000000000000000000..608f471d0f881c789c0ce4e3c4bcba5e8c3b4b7a --- /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 8ee7f9e011a0a90cb67a7ed222cf6d33036df03d..b1b9ecf37fa2ff6e5472f54b9ee4b8dabe72d6de 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 0000000000000000000000000000000000000000..ae6f69d12d7c48ea38a66a136bb306c176fdf919 --- /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 0000000000000000000000000000000000000000..57f26c97974f6637bc1da5e1fbfbc4378b7c76ea --- /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 0000000000000000000000000000000000000000..04a628e0fcc8e6119443a75bd24fc6d378fa55df --- /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 0000000000000000000000000000000000000000..7b5e60571309c23a4c41a02fcbe86fdcca1970e9 --- /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 0000000000000000000000000000000000000000..8cd835dcb5dfde8cf5ae441fbf3421fc4e278463 --- /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 8c8683f7a950c234bff4680b64758d0da0888d1d..75a65d6e7ec836d231d074d672ca05cf0f261645 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 0000000000000000000000000000000000000000..0021576cc817f5baa8b851c2d8192115e879f970 --- /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 0000000000000000000000000000000000000000..bff445b6ad56acfa746d6f0ee07c9cc12c226323 --- /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 0000000000000000000000000000000000000000..e186c0ed207cd98b377569fb376d79f654484fbc --- /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 0000000000000000000000000000000000000000..1be840fa378621729657615789364c333ad17bd3 --- /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); + } +}