2017-10-14 64 views

回答

0

Class<?>是使用未绑定通配符的泛型类型。它的意思是“Class<Foo>某些类型的Foo”。 ClassPathXmlApplicationContext构造函数参数clazz需要该类使用(给定路径的基础)加载资源。

/** 
* Create a new ClassPathXmlApplicationContext, loading the definitions 
* from the given XML file and automatically refreshing the context. 
* <p>This is a convenience method to load class path resources relative to a 
* given Class. For full flexibility, consider using a GenericApplicationContext 
* with an XmlBeanDefinitionReader and a ClassPathResource argument. 
* @param path relative (or absolute) path within the class path 
* @param clazz the class to load resources with (basis for the given paths) 
* @throws BeansException if context creation failed 
* @see org.springframework.core.io.ClassPathResource#ClassPathResource(String, Class) 
* @see org.springframework.context.support.GenericApplicationContext 
* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
*/ 
public ClassPathXmlApplicationContext(String path, Class clazz) throws BeansException { 
    this(new String[] {path}, clazz); 
} 
+0

我正在寻找关于这个javadoc的进一步阐述。在ClasspathXmlApplicationContext的上下文中,这意味着什么类型的资源?这里“相对于给定班级”是什么意思?请详细说明,最好有一些例子或参考文件。 谢谢您的回复! – Forumer

相关问题