Spring入门

简单配置Spring

  1. IDEA新建web项目>>这里这里不做详细解释,看图Spring入门
  2. 添加依赖包pom.xmlSpring入门
    如果你的maven的jar包下载不了可以看这篇博客 https://editor.****.net/md/?articleId=104800142 上面有具体的解决方案。
  3. 在resources目录下,新建applicationContext.xmlSpring入门
  4. applicationContext.xml如下Spring入门
  5. 使用BeanFactory管理bean
    新建User类
    Spring入门
  6. applicationContext.xml文件中,添加如下代码:
  7. 测试,像创建个测试类代码如下
    Spring入门 为什么要使用Spring?
    解耦:指两个或两个以上的体系或两种运动形式间通过相互作用而彼此影响以至 联合起来的现象。
    解耦:减小两个或两个以上的组件关联性