diff --git a/SpringFramework/README.md b/SpringFramework-container/README.md
similarity index 100%
rename from SpringFramework/README.md
rename to SpringFramework-container/README.md
diff --git a/SpringFramework-container/pom.xml b/SpringFramework-container/pom.xml
new file mode 100644
index 0000000..9bd6bc2
--- /dev/null
+++ b/SpringFramework-container/pom.xml
@@ -0,0 +1,20 @@
+
+
+ 4.0.0
+
+ com.linlangjz
+ SpringStudy
+ 1.0-SNAPSHOT
+
+
+ SpringFramework-container
+
+
+
+ org.springframework
+ spring-context
+
+
+
\ No newline at end of file
diff --git a/SpringFramework-container/src/main/java/com/ycjy/Main.java b/SpringFramework-container/src/main/java/com/ycjy/Main.java
new file mode 100644
index 0000000..5b3a284
--- /dev/null
+++ b/SpringFramework-container/src/main/java/com/ycjy/Main.java
@@ -0,0 +1,29 @@
+package com.ycjy;
+
+import com.ycjy.factory.DeptServiceImplFactoryBean;
+import com.ycjy.service.DeptServiceImpl;
+import com.ycjy.service.UserServiceImpl;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Main {
+ public static void main(String[] args) {
+ // 实现了ApplicationContext接口的类型都是容器
+ // 容器对象只创建一次就够了
+ ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
+ UserServiceImpl userService= context.getBean("myUser", UserServiceImpl.class);
+ userService.doSth();
+
+ /* System.out.println(userService.hashCode());
+ UserServiceImpl userService2= context.getBean("myUser", UserServiceImpl.class);
+ System.out.println(userService2.hashCode());
+
+*/
+
+ DeptServiceImpl deptService = context.getBean("dept", DeptServiceImpl.class);
+ deptService.doSth();
+
+ DeptServiceImplFactoryBean o = context.getBean("&dept", DeptServiceImplFactoryBean.class);
+ System.out.println(o);
+ }
+}
\ No newline at end of file
diff --git a/SpringFramework-container/src/main/java/com/ycjy/factory/DeptServiceImplFactoryBean.java b/SpringFramework-container/src/main/java/com/ycjy/factory/DeptServiceImplFactoryBean.java
new file mode 100644
index 0000000..396a11b
--- /dev/null
+++ b/SpringFramework-container/src/main/java/com/ycjy/factory/DeptServiceImplFactoryBean.java
@@ -0,0 +1,30 @@
+package com.ycjy.factory;
+
+import com.ycjy.service.DeptServiceImpl;
+import org.jspecify.annotations.Nullable;
+import org.springframework.beans.factory.FactoryBean;
+
+
+public class DeptServiceImplFactoryBean implements FactoryBean {
+ @Override
+ public @Nullable DeptServiceImpl getObject() throws Exception {
+
+ /* String resource = "org/mybatis/example/mybatis-config.xml";
+ InputStream inputStream = Resources.getResourceAsStream(resource);
+ SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
+ return sqlSessionFactory;*/
+ return new DeptServiceImpl();
+
+ }
+
+ @Override
+ public @Nullable Class> getObjectType() {
+ //return SqlSessionFactory.class;
+ return DeptServiceImpl.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+}
diff --git a/SpringFramework-container/src/main/java/com/ycjy/service/DeptServiceImpl.java b/SpringFramework-container/src/main/java/com/ycjy/service/DeptServiceImpl.java
new file mode 100644
index 0000000..5687efd
--- /dev/null
+++ b/SpringFramework-container/src/main/java/com/ycjy/service/DeptServiceImpl.java
@@ -0,0 +1,7 @@
+package com.ycjy.service;
+
+public class DeptServiceImpl {
+ public void doSth(){
+ System.out.println("===doSth ===in deptServiceImpl");
+ }
+}
diff --git a/SpringFramework-container/src/main/java/com/ycjy/service/UserServiceImpl.java b/SpringFramework-container/src/main/java/com/ycjy/service/UserServiceImpl.java
new file mode 100644
index 0000000..fa24982
--- /dev/null
+++ b/SpringFramework-container/src/main/java/com/ycjy/service/UserServiceImpl.java
@@ -0,0 +1,30 @@
+package com.ycjy.service;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class UserServiceImpl implements BeanNameAware , ApplicationContextAware {
+ private UserServiceImpl(){
+ System.out.println("----user constructor");
+ }
+ public void doSth(){
+ System.out.println(this.name + "---doSth ---in userServiceImpl");
+
+ }
+
+ private String name;
+
+ @Override
+ public void setBeanName(String name) {
+ this.name = name;
+ }
+
+ private ApplicationContext context;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.context = applicationContext;
+ }
+}
diff --git a/SpringFramework/src/main/resources/spring-config.xml b/SpringFramework-container/src/main/resources/spring-config.xml
similarity index 64%
rename from SpringFramework/src/main/resources/spring-config.xml
rename to SpringFramework-container/src/main/resources/spring-config.xml
index 4e6be91..264e2a3 100644
--- a/SpringFramework/src/main/resources/spring-config.xml
+++ b/SpringFramework-container/src/main/resources/spring-config.xml
@@ -2,6 +2,7 @@
-
-
+
+
+
\ No newline at end of file
diff --git a/SpringFramework/pom.xml b/SpringFramework-ioc/pom.xml
similarity index 93%
rename from SpringFramework/pom.xml
rename to SpringFramework-ioc/pom.xml
index 42a7321..0ffa0be 100644
--- a/SpringFramework/pom.xml
+++ b/SpringFramework-ioc/pom.xml
@@ -9,7 +9,7 @@
1.0-SNAPSHOT
- SpringFramework
+ SpringFramework-ioc
diff --git a/SpringFramework-ioc/src/main/java/com/ycjy/Main.java b/SpringFramework-ioc/src/main/java/com/ycjy/Main.java
new file mode 100644
index 0000000..14a0d00
--- /dev/null
+++ b/SpringFramework-ioc/src/main/java/com/ycjy/Main.java
@@ -0,0 +1,18 @@
+package com.ycjy;
+
+import com.ycjy.service.DeptService;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Main {
+ public static void main(String[] args) {
+ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
+
+// DeptDao userService = context.getBean("userDao", DeptDao.class);
+// userService.doSth();
+
+ DeptService deptService = context.getBean("deptService", DeptService.class);
+ deptService.doSth();
+
+ }
+}
\ No newline at end of file
diff --git a/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDao.java b/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDao.java
new file mode 100644
index 0000000..1f7777f
--- /dev/null
+++ b/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDao.java
@@ -0,0 +1,5 @@
+package com.ycjy.dao;
+
+public interface DeptDao {
+ void doSth();
+}
diff --git a/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDaoImpl.java b/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDaoImpl.java
new file mode 100644
index 0000000..236d4c6
--- /dev/null
+++ b/SpringFramework-ioc/src/main/java/com/ycjy/dao/DeptDaoImpl.java
@@ -0,0 +1,8 @@
+package com.ycjy.dao;
+
+public class DeptDaoImpl implements DeptDao {
+ @Override
+ public void doSth(){
+ System.out.println("dosth in deptDao impl----");
+ }
+}
diff --git a/SpringFramework-ioc/src/main/java/com/ycjy/service/DeptService.java b/SpringFramework-ioc/src/main/java/com/ycjy/service/DeptService.java
new file mode 100644
index 0000000..21fea49
--- /dev/null
+++ b/SpringFramework-ioc/src/main/java/com/ycjy/service/DeptService.java
@@ -0,0 +1,5 @@
+package com.ycjy.service;
+
+public interface DeptService {
+ void doSth();
+}
diff --git a/SpringFramework-ioc/src/main/java/com/ycjy/service/impl/DeptServiceImpl.java b/SpringFramework-ioc/src/main/java/com/ycjy/service/impl/DeptServiceImpl.java
new file mode 100644
index 0000000..db3c4f2
--- /dev/null
+++ b/SpringFramework-ioc/src/main/java/com/ycjy/service/impl/DeptServiceImpl.java
@@ -0,0 +1,31 @@
+package com.ycjy.service.impl;
+
+import com.ycjy.dao.DeptDao;
+import com.ycjy.service.DeptService;
+
+public class DeptServiceImpl implements DeptService {
+
+ private String test1;
+
+ private DeptDao deptDao ;
+
+ public DeptServiceImpl(DeptDao deptDao) {
+ this.deptDao = deptDao;
+ }
+
+ public DeptServiceImpl(String d, DeptDao deptDao) {
+ this.test1 = d;
+ this.deptDao = deptDao;
+ }
+
+ public void setDeptDao(DeptDao deptDao) {
+ this.deptDao = deptDao;
+ }
+
+ @Override
+ public void doSth(){
+ System.out.println(this.test1 );
+ deptDao.doSth();
+ System.out.println("dosth in DeptService impl----");
+ }
+}
diff --git a/SpringFramework-ioc/src/main/resources/applicationContext.xml b/SpringFramework-ioc/src/main/resources/applicationContext.xml
new file mode 100644
index 0000000..d17f257
--- /dev/null
+++ b/SpringFramework-ioc/src/main/resources/applicationContext.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SpringFramework/src/main/java/com/ycjy/Main.java b/SpringFramework/src/main/java/com/ycjy/Main.java
deleted file mode 100644
index 8ac6ecb..0000000
--- a/SpringFramework/src/main/java/com/ycjy/Main.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.ycjy;
-
-import com.ycjy.entity.User;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class Main {
- public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
- User myUser = context.getBean("myUser", User.class);
- System.out.println("code:" + myUser.hashCode());
- System.out.println(myUser);
- System.out.println("code:" + myUser.hashCode());
- }
-}
\ No newline at end of file
diff --git a/SpringFramework/src/main/java/com/ycjy/entity/User.java b/SpringFramework/src/main/java/com/ycjy/entity/User.java
deleted file mode 100644
index c119337..0000000
--- a/SpringFramework/src/main/java/com/ycjy/entity/User.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.ycjy.entity;
-
-public class User {
-
-}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c168db3..0d774a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,8 @@
1.0-SNAPSHOT
pom
- SpringFramework
+ SpringFramework-container
+ SpringFramework-ioc