提交 02ab1cf9 编写于 作者: Q qinyingjie

fix:测试添加编号

上级 2a2f9db1
package com.kwan.spring5;
/**
* 部门
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 20:00
*/
public class Dept {
/**
* 名称
*/
private String dname;
public void setDname(String dname) {
this.dname = dname;
}
@Override
public String toString() {
return "Dept{" +
"dname='" + dname + '\'' +
'}';
}
}
package com.kwan.spring5;
/**
* 员工
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 20:01
*/
public class Emp {
/**
* 姓名
*/
private String ename;
/**
* 性别
*/
private String gender;
/**
* 员工属于某一个部门,使用对象形式表示
*/
private Dept dept;
public void setDept(Dept dept) {
this.dept = dept;
}
public void setEname(String ename) {
this.ename = ename;
}
public void setGender(String gender) {
this.gender = gender;
}
@Override
public String toString() {
return "Emp{" +
"ename='" + ename + '\'' +
", gender='" + gender + '\'' +
", dept=" + dept +
'}';
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<!--内部bean-->
<bean id="emp" class="com.kwan.spring5.Emp">
<!--设置两个普通属性-->
<property name="ename" value="Andy"></property>
<property name="gender" value="女"></property>
<!--设置对象类型属性-->
<property name="dept">
<bean class="com.kwan.spring5.Dept"><!--内部bean赋值-->
<property name="dname" value="宣传部门"></property>
</bean>
</property>
</bean>
</beans>
\ No newline at end of file
......@@ -10,7 +10,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class UserTest {
public class Spring_01_XmlGetTest {
@Test
public void test1() {
......@@ -30,7 +30,4 @@ public class UserTest {
User user = (User) ctx.getBean("user");
user.say();
}
}
//1.修改快捷键爱你
//2.修改测试类名
\ No newline at end of file
}
\ No newline at end of file
import com.kwan.spring5.User;
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_02_UserTest {
@Test
public void test1() {
System.out.println("test1");
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("spring1.xml");
User user = (User) ctx.getBean("user");
user.say();
}
@Test
public void test2() {
System.out.println("test2");
ApplicationContext ctx =
new ClassPathXmlApplicationContext("spring1.xml");
User user = (User) ctx.getBean("user");
user.say();
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class OrdersTest {
public class Spring_03_OrdersTest {
@Test
public void test1() {
......
......@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class BookTest_01 {
public class Spring_04_BookTest_01 {
@Test
public void test1() {
......
......@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class BookTest_02 {
public class Spring_04_BookTest_02 {
@Test
public void test1() {
......
......@@ -10,7 +10,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class BookTest_03 {
public class Spring_04_BookTest_03 {
@Test
public void test1() {
......
......@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public class UserServiceTest {
public class Spring_05_UserServiceTest {
@Test
public void test2() {
......
import com.kwan.spring5.Emp;
import com.kwan.spring5.User;
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 {
@Test
public void test1() {
ApplicationContext ctx =
new ClassPathXmlApplicationContext("spring5.xml");
Emp emp = (Emp) ctx.getBean("emp");
System.out.println(emp);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册