2017-10-14 5 views
0

このメソッドのJavadocについて理解してください。 2番目の引数は返されるコンテキストにどのように影響しますか?ClassPathXmlApplicationContext(String path、Class <?> clazz)の2番目の引数は何ですか

これは、指定されたクラス に対するクラスパスリソースをロードするための便利な方法です。完全な柔軟性を得るには、XmlBeanDefinitionReaderと ClassPathResource引数を使用して GenericApplicationContextを使用することを検討してください。

答えて

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

関連する問題