首页>代码>spring bean通过@Lazy注解实现延迟初始化实例>/lazy-initialize-@autowired-dependency-@lazy-example/src/main/java/com/memorynotfound/spring/core/lazy/Run.java
package com.memorynotfound.spring.core.lazy;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Run {

    public static void main(String... args) throws InterruptedException {
        ApplicationContext context = new ClassPathXmlApplicationContext("app-config.xml");
        System.out.println("Application context loaded");
        System.out.println("Getting Person Bean");
        Person person = context.getBean(Person.class);

        System.out.println("Waiting...");
        Thread.sleep(1000);

        System.out.println("Getting the address");
        Address address = person.getAddress();
        System.out.println(address);
    }
}
最近下载更多
最代码-宋家辉  LV61 2021年11月7日
最近浏览更多
80730176  LV7 2023年11月28日
szf123  LV12 2023年5月30日
我睡觉时不困  LV7 2022年10月30日
2468867327  LV10 2022年5月17日
xp95323  LV14 2022年1月25日
最代码-宋家辉  LV61 2021年11月7日
好好必须的快乐 2021年10月30日
暂无贡献等级
moonquake_lin  LV2 2021年9月8日
neikoneiko  LV9 2021年6月4日
xiao菜  LV2 2021年6月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友