|
@@ -1,5 +1,7 @@
|
|
|
-package com.sf;
|
|
|
+package com.sf.ioc;
|
|
|
|
|
|
+import com.sf.ioc.simple.Role;
|
|
|
+import com.sf.ioc.simple.User;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
@@ -10,7 +12,7 @@ public class TestBean {
|
|
|
public void test(){
|
|
|
|
|
|
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean.xml");
|
|
|
User user = (User) context.getBean("user");
|
|
|
|
|
|
System.out.println(user);
|
|
@@ -21,7 +23,7 @@ public class TestBean {
|
|
|
|
|
|
@Test
|
|
|
public void testOther(){
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean-other.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean-other.xml");
|
|
|
|
|
|
Role role = (Role)context.getBean("role");
|
|
|
System.out.println(role);
|
|
@@ -29,7 +31,7 @@ public class TestBean {
|
|
|
|
|
|
@Test
|
|
|
public void testBean(){
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean-other.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean-other.xml");
|
|
|
|
|
|
Role role0 = (Role)context.getBean("role");
|
|
|
System.out.println(role0);
|
|
@@ -76,7 +78,7 @@ public class TestBean {
|
|
|
|
|
|
@Test
|
|
|
public void testAll(){
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean.xml");
|
|
|
Role role = context.getBean("role",Role.class);
|
|
|
System.out.println(role);
|
|
|
|
|
@@ -86,8 +88,8 @@ public class TestBean {
|
|
|
@Test
|
|
|
public void testConst(){
|
|
|
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
|
-
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean.xml");
|
|
|
+
|
|
|
|
|
|
User user1 = context.getBean("user1",User.class);
|
|
|
System.out.println(user1);
|
|
@@ -95,10 +97,10 @@ public class TestBean {
|
|
|
|
|
|
@Test
|
|
|
public void testSpecial(){
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean.xml");
|
|
|
|
|
|
|
|
|
- User user = context.getBean("user2",User.class);
|
|
|
+ User user = context.getBean("user2", User.class);
|
|
|
System.out.println(user);
|
|
|
|
|
|
|
|
@@ -106,7 +108,7 @@ public class TestBean {
|
|
|
|
|
|
@Test
|
|
|
public void testRef(){
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -114,7 +116,7 @@ public class TestBean {
|
|
|
|
|
|
|
|
|
|
|
|
- ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
|
|
|
+ ApplicationContext context = new ClassPathXmlApplicationContext("ioc/bean.xml");
|
|
|
User user = context.getBean("user",User.class);
|
|
|
System.out.println(user);
|
|
|
|