Questions about the Spring XML file?

Asked

Viewed 302 times

3

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

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

OBS: I’m in the learning phase. I’m sorry if I’m being ignorant.

Thank you in advance for your attention.

2 answers

3


By answering your questions:

Where I create the Spring xml file?

If you are using a Maven archetype, put it in the project’s Resources folder (src/main/Resources).

What name do I give to the xml file?

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

XML would be the settings for Spring dependency injection ?

In a way, 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 jot them down (@Component).

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

Currently developers have used CDI more for this purpose, and that’s what I strongly recommend you to use. Then do some digging, it’ll be worth it.

1

Utilize Spring Boot and escape unnecessary Xmls by performing all convention settings and application claspath tracking.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.