Tôi mới vào khung mùa xuân. Tôi đang cố gắng để biết danh sách các tập tin xml được tham chiếu trong khi tải đậu.cách biết tài nguyên mà từ đó một hạt được nạp vào dự án mùa xuân.
Bằng cách viết một lớp học đó là ApplicationContextAware, i am có thể xem danh sách các hạt cà phê với:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/sample-testcontext.xml")
public class SampleClass implements ApplicationContextAware {
@Autowired
ApplicationContext applicationContext;
@Test
public void testMethod() {
for (String beanName : applicationContext.getBeanDefinitionNames()) {
System.out.println("BeanName " + beanName);
}
}
}
Nhưng tôi muốn biết từ những tập tin cấu hình hạt cà phê được nạp.
Say "mẫu-testcontext.xml" chứa
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<beans:import resource="classpath*:spring/sample-testOneMorecontext.xml"/>
</beans:beans>
Tôi muốn biết danh sách các tên tập tin mà từ đó đậu được nạp như "mẫu-testOneMorecontext.xml" và "sample-testcontext.xml".