ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); Resource resource = resourcePatternResolver.getResource("classpath:META-INF/spring/sofa-rpc-consumer.xml"); System.out.println(resource.getURL()); DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(defaultListableBeanFactory); reader.loadBeanDefinitions(resource); String[] beans = defaultListableBeanFactory.getBeanDefinitionNames(); for (String s: beans) { System.err.println(s); }