Junior — Middle
Can you name the main initial components and modules used within Spring?
sobes.tech AI
Answer from AI
The main initial components and modules of Spring include:
- Core Container — the core container that provides inversion of control (IoC) and dependency injection (DI) functionality. Includes modules
spring-core,spring-beans,spring-context. - Spring AOP — a module for aspect-oriented programming, allowing separation of cross-cutting concerns (logging, transactions).
- Data Access/Integration — modules for working with databases, including
spring-jdbc,spring-orm(Hibernate, JPA),spring-txfor transaction management. - Web — modules for creating web applications, including
spring-web,spring-webmvc(Spring MVC).
Example of simple Spring IoC usage:
@Configuration
public class AppConfig {
@Bean
public MyService myService() {
return new MyServiceImpl();
}
}
@Component
public class MyComponent {
private final MyService service;
@Autowired
public MyComponent(MyService service) {
this.service = service;
}
}