Questions about the Spring XML file?

3

I'm developing an application that uses JAVA SE + SPRING. I have some questions regarding XML:

  • Where do I create the file xml of Spring ?
  • What is the name I give to arquivo xml ?
  • The XML would be the settings for the Spring dependency injection ?

NOTE: I am in the learning phase. I'm sorry if I'm being ignorant.

Thank you in advance for your attention.

    
asked by anonymous 01.09.2016 / 21:21

2 answers

3

Answering your questions:

  

Where do I create the Spring xml file?

If you are using a maven archetype, put it in the project resources folder (src / main / resources).

  

What is the name I give to the xml file?

It can be any one, but it is usually context.xml or applicationContext.xml because it is a file that declares what will be the Spring context in the application.

  

Would the XML be the settings for the Spring dependency injection?

In general terms, yes. But keep in mind that in newer versions of Spring it is possible to use annotations and then you no longer need to declare your beans in an xml file, just simply annotate them (@Component).

The Spring framework allows you to better manage an application's dependencies using the concept of dependency injection. I really like the Mkyong tutorials and so I'm going to give you a link that is exactly about Spring:

Currently the developers have used more CDI for this purpose, and that's what I strongly recommend you to use. Then give it a look at it, it will be worth it.

    
01.09.2016 / 23:16
1

Use Spring Boot and flee unnecessary XMLs, performing all configurations by convention and tracking the application's claspath

    
13.02.2017 / 15:49