问题描述
我正在尝试在IntellIJ中开发一个基于示例Spring Boot的应用程序.因此,我使用spring Initialzr方法,并在设置过程中进行了默认选择.我最终得到的pom.xml具有以下依赖关系:
I am trying to develop a sample spring boot based application in IntellIJ. So I used spring Initialzr approach, and made default selections during the setup. The pom.xml I ended up with has following dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
但是我关注的教程如下:
But the tutorial I am following has following:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
那么,有什么区别?我可以同时拥有吗?
So, what's the difference? And can I have both?
推荐答案
spring-boot-starter-web包含以下依赖项:
spring-boot-starter-web contains the following dependencies:
- spring-boot-starter
- jackson
- spring-core
- spring-mvc
- spring-boot-starter-tomcat
使用IntelliJ,您可以在项目结构的底部查看工件的依赖性.
Using IntelliJ, you can view the dependencies of your artifacts at the bottom of the project structure.
鉴于spring-boot-starter是spring-boot-starter-web的依赖项,因此两者都没有用.如果两者都保留,则不会有任何危害,只是不必要的.
Given that spring-boot-starter is a dependency of spring-boot-starter-web, it would be useless to have both. It wouldn't do any harm if you kept both either, just unnecessary.
这篇关于spring initializr:spring-boot-starter vs spring-boot-starter-web的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!