首页>代码>Spring自定义ThreadLocal Scope实现类:ThreadScope>/spring-custom-scope-thread-scope-example/src/main/java/com/memorynotfound/spring/core/scope/Run.java
package com.memorynotfound.spring.core.scope;

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("ApplicationContext initialized");

        System.out.println("Retrieve '最代码 Register'");
        Register register1 = context.getBean(Register.class);
        System.out.println("Retrieve '最代码 Register' again");
        Register register2 = context.getBean(Register.class);
        System.out.println("Register1 == Register2: " + (register1 == register2));

        System.out.println("Clear thread scope");
        ThreadScope threadScope = context.getBean(ThreadScope.class);
        threadScope.clear();

        System.out.println("Retrieve '最代码 Register'");
        Register register3 = context.getBean(Register.class);
        System.out.println("Retrieve '最代码 Register' again");
        Register register4 = context.getBean(Register.class);
        System.out.println("Register3 == Register4: " + (register3 == register4));
    }
}
最近下载更多
最近浏览更多
szf123  LV12 2023年5月30日
xiao菜  LV2 2021年6月2日
srl2881552  LV10 2021年5月20日
leon528616  LV2 2021年5月20日
3399509525  LV5 2021年4月14日
kayok  LV19 2021年3月16日
8763804  LV2 2021年3月10日
crowd_lu 2021年2月28日
暂无贡献等级
wghai2 2021年2月27日
暂无贡献等级
xdd211414  LV17 2021年2月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友