mcfly soft
mcfly soft

Reputation: 11665

application.properties versus applicationContext.xml

I have a running spring boot sample application with the configuration for Hibernate and else stored in the application.properties file.

Reading through the docs I am wondering where the applicationContext.xml comes in place? Is this encapsulated by @SpringBootApplication?

Upvotes: 1

Views: 3231

Answers (1)

Maciej Kowalski
Maciej Kowalski

Reputation: 26562

applicationContext.xml contains bean definitions and relations, application.properties is just for general system configuration.

Normally you would go the Annotation / Java based configuration but if you happen to have some legacy beans xml config that you would like to use, then you would normally place it under:

src/main/resources/applicationContext.xml

and then create a class with appropriate configuration annotations:

@Configuration
@ImportResource({"classpath*:applicationContext.xml"})
public class LegacyXmlConfiguration {}

just make sure that this class is part of the spring boot's packages to scan.

Upvotes: 2

Related Questions