Posts

Showing posts with the label @ImportResource

Spring @ImportResource Annotation Example

Image
In this section we will learn about @ImportResource  Annotation. The  @ImportResource  annotation is used to load beans from an XML configuration file into an Application Context in Java configuration based applications. The class annotated with @Configuration can use @ImportResource annotation to load XML configurations. For example, old application based on XML configuration is being upgraded to Java configuration based application, to keep bean definition at both places, in Java configuration as well as XML configuration , we can use @ImportResource annotation.     @Configuration @ImportResource ( "classpath:/app-config.xml" ) public class AppConfig { .............. } The following example creates a Spring Boot application which uses @ImportResource annotation. Project Directory pom.xml <? xml version ="1.0" encoding ="UTF-8" ?> < project xmlns ="http://maven.apache.org/POM/4.0.0" xmlns: xsi ="http://www.w3.org/20