diff --git a/pom.xml b/pom.xml index cbb7967ecbd91004230825e70249caaf0a3074fd..6822ae1babef013127b2c5d5caaa24d92b24ff74 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,13 @@ commons-logging 1.2 + + + junit + junit + 4.12 + test + \ No newline at end of file diff --git a/src/main/java/com/kwan/spring5/User.java b/src/main/java/com/kwan/spring5/User.java new file mode 100644 index 0000000000000000000000000000000000000000..9f1da9024237eebd57e7e381e55f62d59bcf2e5c --- /dev/null +++ b/src/main/java/com/kwan/spring5/User.java @@ -0,0 +1,8 @@ +package com.kwan.spring5; + +public class User { + + public void say() { + System.out.println("访问user成功"); + } +} diff --git a/src/main/resources/spring1.xml b/src/main/resources/spring1.xml new file mode 100644 index 0000000000000000000000000000000000000000..66b072480f16fe0cc02e817449e79b1741c77672 --- /dev/null +++ b/src/main/resources/spring1.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/src/test/java/BeanTest.java b/src/test/java/BeanTest.java new file mode 100644 index 0000000000000000000000000000000000000000..eb59fca3172ca2380eec0ff538cfb45ba227744d --- /dev/null +++ b/src/test/java/BeanTest.java @@ -0,0 +1,14 @@ +import com.kwan.spring5.User; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class BeanTest { + + @Test + public void test1() { + ClassPathXmlApplicationContext ctx = + new ClassPathXmlApplicationContext("spring1.xml"); + User user = (User) ctx.getBean("user"); + user.say(); + } +}