Spring5源码分析之IOC-基本使用-1

Spring5已经出来了,出于好奇心,想看看Spring5的源码到底怎么样,因为最低兼容JDK8,所以肯定是用了lambda和Stream的东西,想看看Spring4当中冗杂的代码是否得到了精简。先从一个简单的Spring的IOC例子开始。

为了更好的分析Spring5的源码,我决定使用xml配置,因为xml配置对于bean的关系很明显:

Java代码如下:

@Test
    public void jdkSelfClass(){
        ApplicationContext context = new ClassPathXmlApplicationContext("./spring.xml");
        SimpleDateFormat dateFormat = context.getBean(SimpleDateFormat.class);
        logger.info("DateFormat:{}",dateFormat);
    }

XML配置如下:

<?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:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
    <bean id="dataFormat" class="java.text.SimpleDateFormat">
    </bean>
</beans>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容