The config location defaults can be overridden via getConfigLocations,
Config locations can either denote concrete files like "/myfiles/context.xml"
or Ant-style patterns like "/myfiles/*-context.xml" (see the
org. javadoc for pattern details).
Note
In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files. This can be leveraged to deliberately override certain bean definitions via an extra XML file.
This is a simple, one-stop shop convenience ApplicationContext.
Consider using the GenericApplicationContext class in combination
with an org.
for more flexible context setup.
getResource, getResourceByPath, GenericApplicationContext
| Modifier and Type | Field and Description |
|---|---|
| private Resource[] |
| Access | Constructor and Description |
|---|---|
| public | ClassPathXmlApplicationContext()
Create a new ClassPathXmlApplicationContext for bean-style configuration. |
| public | ClassPathXmlApplicationContext(ApplicationContext
the parent context parent)Create a new ClassPathXmlApplicationContext for bean-style configuration. |
| public | ClassPathXmlApplicationContext(String
resource location configLocation)Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML file and automatically refreshing the context. |
| public | ClassPathXmlApplicationContext(String...
array of resource locations configLocations)Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context. |
| public | ClassPathXmlApplicationContext(String[]
array of resource locations configLocations, ApplicationContext the parent context parent)Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files and automatically refreshing the context. |
| public | ClassPathXmlApplicationContext(String[]
array of resource locations configLocations, boolean whether to automatically refresh the context,
loading all bean definitions and creating all singletons.
Alternatively, call refresh manually after further configuring the context. refresh)Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files. |
| public | ClassPathXmlApplicationContext(String[]
array of resource locations configLocations, boolean whether to automatically refresh the context,
loading all bean definitions and creating all singletons.
Alternatively, call refresh manually after further configuring the context. refresh, ApplicationContext the parent context parent)Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files. |
| public | ClassPathXmlApplicationContext(String
relative (or absolute) path within the class path path, Class<?> the class to load resources with (basis for the given paths) clazz)Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML file and automatically refreshing the context. |
| public | ClassPathXmlApplicationContext(String[]
array of relative (or absolute) paths within the class path paths, Class<?> the class to load resources with (basis for the given paths) clazz)Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context. |
| public | ClassPathXmlApplicationContext(String[]
array of relative (or absolute) paths within the class path paths, Class<?> the class to load resources with (basis for the given paths) clazz, ApplicationContext the parent context parent)Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files and automatically refreshing the context. |
| Modifier and Type | Method and Description |
|---|---|
| protected Resource[] | getConfigResources()
Overrides org. Return an array of Resource objects, referring to the XML bean definition files that this context should be built with. |
| configResources | back to summary |
|---|---|
| private Resource[] configResources
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext() Create a new ClassPathXmlApplicationContext for bean-style configuration. | |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(ApplicationContext parent) Create a new ClassPathXmlApplicationContext for bean-style configuration.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String configLocation) throws BeansException Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML file and automatically refreshing the context.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String... configLocations) throws BeansException Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String[] configLocations, ApplicationContext parent) throws BeansException Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files and automatically refreshing the context.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh) throws BeansException Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String[] configLocations, boolean refresh, ApplicationContext parent) throws BeansException Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String path, Class<?> clazz) throws BeansException Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML file and automatically refreshing the context. 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.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String[] paths, Class<?> clazz) throws BeansException Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.
| |
| ClassPathXmlApplicationContext | back to summary |
|---|---|
| public ClassPathXmlApplicationContext(String[] paths, Class<?> clazz, ApplicationContext parent) throws BeansException Create a new ClassPathXmlApplicationContext with the given parent, loading the definitions from the given XML files and automatically refreshing the context.
| |
| getConfigResources | back to summary |
|---|---|
| protected Resource[] getConfigResources() Overrides org. Doc from org. Return an array of Resource objects, referring to the XML bean definition files that this context should be built with. The default implementation returns | |