Junior — Middle
What is the main role of the Proxy pattern in software development?
sobes.tech AI
Answer from AI
The @Import annotation in Spring Framework is used to import configuration classes or components into the current application context. This allows splitting configuration into multiple classes and including them as needed.
How it works: when using @Import, Spring loads the specified classes as beans into the context, which is equivalent to declaring these classes with @Configuration or registering components manually.
Example:
@Configuration
@Import({DataSourceConfig.class, SecurityConfig.class})
public class AppConfig {
// Beans from DataSourceConfig and SecurityConfig are available here
}
Thus, @Import helps structure configuration and reuse it across different parts of the application.