How to get an instance of ApplicationContext in a JUnit unit test case

public class TPlatformInfoTest extends TestBase{
    
    private static MyHttpClient TPlatformInfoDispose;
    
    @BeforeClass
    public static void setUpBeforeClass(){
        System.out.println("***********here init first***************");
        TPlatformInfoDispose = new MyHttpClient("platform");
        DataSourceContextHolder.setDbType("ds2");
        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:WEB-INF/rest-*.xml");
        pfm = ctx.getBean(TPlatformInfoMapper.class);
        dim = ctx.getBean(TDeviceInfoMapper.class);
    }
copy code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324848507&siteId=291194637