Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring-boot automatically import applicationContext.xml?

I'm using spring-boot and would like to automatically import src/main/resources/applicationContext.xml file.

So far it only works if I explicit tell spring to import it:

@EnableAutoConfiguration
@Configuration
@ImportResource({"classpath*:applicationContext.xml"})

But spring-boot has so many default, maybe someone knows the "default" name for the app.xml file so that is gets picked up by spring-boot by default?

like image 204
membersound Avatar asked Sep 05 '14 14:09

membersound


People also ask

Where is ApplicationContext xml in Spring boot?

src/main/resources/applicationContext.xml: properties in src/main/resources too.

How do I load a spring context file in web xml?

Spring can be easily integrated into any Java-based web framework. All you need to do is to declare the ContextLoaderListener in your web. xml and use a contextConfigLocation to set which context files to load. You can then use the WebApplicationContext to get a handle on your beans.

Is required to load the beans configured in ApplicationContext XML file?

ClassPathXmlApplicationContext − This container loads the definitions of the beans from an XML file. Here you do not need to provide the full path of the XML file but you need to set CLASSPATH properly because this container will look like bean configuration XML file in CLASSPATH.


1 Answers

There is no such feature for importing an XML configuration by default based on it's name or location.

Check out this part of the documentation.

like image 89
geoand Avatar answered Oct 14 '22 01:10

geoand