Class<?>
est un type générique utilisant un caractère générique non lié. cela signifie "Class<Foo>
pour un certain type de Foo". ClassPathXmlApplicationContext Le paramètre constructeur clazz prend la classe pour charger les ressources avec (base pour les chemins donnés).
/**
* 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);
}
Je suis à la recherche d'une élaboration plus poussée sur ce javadoc. Quels types de ressources cela signifie-t-il dans le contexte de ClasspathXmlApplicationContext? Que signifie "par rapport à une classe donnée" ici? Veuillez élaborer, de préférence, avec un exemple ou une référence à une documentation. Merci pour votre réponse! – Forumer