32

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?

3
  • is it part of a web-application? Commented Sep 5, 2014 at 14:13
  • If it's a part of web application then you can use default name to load spring application context. If the name of servlet-name is xyz for DispatcherServlet in web.xml then it will load xyz-servlet.xml file automatically from class-path where you can import other spring configuration files using <import resource="abc.xml" /> Commented Sep 5, 2014 at 14:24
  • It's a simple webapplication that should host a single SOAP webservice. So I have no explicit servlet name. The soap is wired by cxf. Commented Sep 5, 2014 at 14:34

1 Answer 1

23

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Correct. However, spring boot application can be used to import .properties (.yml) files automatically from classpath as a part of @EnableAutoConfiguration module.
@AbhishekShah That is true and is meant to include configuration properties. What OP is asking is whether or not a way Spring Boot would automatically import any specific XML files that define Spring beans
Agreed. Apologized for misunderstood. There no such kind of feature for auto import XML file for spring beans. You must have to specify it in your configuration class.
Link is dead 123
Thanks @DrunkenPoney, fixed now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.