1、文件的位置:
resource/spring/ApplicationContext.xml
2、使用FileSystemXmlApplicationContext读取文件
String path = this.getClass().getClassLoader().getResource("").getPath();
String filepath = "file:"+ path + "spring/ApplicationContext.xml";
applicationContext = new FileSystemXmlApplicationContext(filepath);
3、获取类
ObsMapper obsMapper = applicationContext.getBean(ObsMapper.class);
参考文档:
https://blog.csdn.net/xxxknight/article/details/46671355