【发布时间】:2020-03-26 10:27:42
【问题描述】:
如果我创建一个自定义的 Spring Boot 启动模块,是否需要包含依赖项 spring-boot-starter ?
- 一些初学者将依赖
spring-boot-starter添加到其pom.xml(spring-boot-starter-web,spring-boot-starter-thymeleaf) - 其他一些初学者没有(spring-boot-starter-log4j2、spring-boot-starter-undertow、spring-boot-starter-tomcat)。
是否有理由不将其添加到依赖项中?
【问题讨论】:
-
不需要包含 spring-boot-starter 的依赖。仅当您需要自己的启动器的传递依赖项时。但是你的启动器不应该以 spring-* 开头。关键字 spring 是保留的。前缀应该是您的启动器的名称。例如见baeldung.com/spring-boot-custom-starter
-
我已经知道我的启动器不应该以 spring-* 开头,这不是我的问题。在 baldung 示例中,启动项目包含对 spring-boot-starter 的依赖项,因为它不使用它到自定义启动程序中。
标签: spring-boot spring-boot-starter