Spring Boot Starters
Starters (web, data-jpa, security, test), transitive dependencies, BOM, custom starters
1What is a Spring Boot Starter?
What is a Spring Boot Starter?
回答
A starter is a dependency descriptor that automatically bundles all necessary libraries for a specific use case, with compatible versions tested together. This eliminates the need to manually search for each dependency and automatically manages transitive dependencies. For example, spring-boot-starter-web includes Spring MVC, embedded Tomcat, Jackson for JSON, and all their compatible dependencies.
2What is the naming convention for official Spring Boot starters?
What is the naming convention for official Spring Boot starters?
回答
All official Spring Boot starters follow the naming convention spring-boot-starter-*, where the asterisk represents the type of application or functionality. This convention allows immediately distinguishing official starters maintained by the Spring Boot team from community-created third-party starters which use the reverse pattern *-spring-boot-starter. This distinction is important for trust and compatibility. Official examples: spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-security.
3What is the role of spring-boot-starter-parent in a project?
What is the role of spring-boot-starter-parent in a project?
回答
The spring-boot-starter-parent is a Maven parent POM that provides centralized version management for all Spring Boot dependencies and compatible third-party libraries. It also defines default Maven configurations such as UTF-8 encoding, Java version, and build plugins. Thanks to it, there is no need to specify versions for managed dependencies, which ensures compatibility and simplifies maintenance.
What are transitive dependencies in a starter?
Which starter to use for creating a REST web application with Spring Boot?
+15 面接問題