You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

808 B

框架源码的前置知识

  • 设计模式
  • 数据结构与算法
  • 反射
  • 多线程
  • JVM

IOC控制反转 DI依赖注入

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" abstract="xxx" autowire="byName" autowire-candidate="default" depends-on="environment" init-method="afterPropertiesSet">
        <!-- 注入数据库连接池 -->
        <property name="dataSource" ref="dataSource"/>
    </bean>
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml")
XXX xxbean = context.getBean(XXX.class);
xxbean.method();

SSM框架项目中spring处理bean的主要流程

  • 加载xml文件
  • 解析xml文件
  • 封装BeanDefinition
  • 实例化
  • 放到容器中
  • 从容器中获取