Skip to main content


Showing posts with the label Spring @Import annotation

Spring Core - @Import annotation

In this post, we will learn about @Import annotation and its usage. You can see my previous post on how to create a simple spring core project. What is @Import annotation and usage? @Import annotation is equivalent to <import/> element in Spring XML configuration. It helps in splitting the single Java based configuration file into small, modular, maintainable and component based configuration. Let's see it with example. @Configuration @Import(value = { DBConfig.class, WelcomeGbConfig.class }) public class HelloGbAppConfig { } In above code snippet, we are importing two different configuration files viz. DBConfig , WelcomeGbConfig in application level configuration file HelloGbAppConfig . The above code is equivalent to Spring XML based configuration below. <beans xmlns="" xmlns:xsi="" xsi:schemaLocation="