• 在spring4之后,想要使用注解形式,必须得要引入aop的包
    IOC注解方式1.0 随笔 第1张

  • 在配置文件当中,还得要引入一个context约束
    IOC注解方式1.0 随笔 第2张

    SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
          <?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
                  http://www.springframework.org/schema/beans/spring-beans.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context.xsd">
    
          </beans>
  • 配置组件扫描
    哪个包下的类型使用组合扫描
    IOC注解方式1.0 随笔 第3张

  • 使用注解注入属性
    可以不用提供set方法,直接在直接名上添加@value("值")
    如果提供了set方法,在set方法上添加@value("值");
    IOC注解方式1.0 随笔 第4张
    IOC注解方式1.0 随笔 第5张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄