企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 11.2. 添加classpath依赖 ### 11.2. 添加classpath依赖 Spring Boot提供很多"Starters",用来简化添加jars到classpath的操作。示例程序中已经在POM的`parent`节点使用了`spring-boot-starter-parent`,它是一个特殊的starter,提供了有用的Maven默认设置。同时,它也提供一个`dependency-management`节点,这样对于期望(”blessed“)的依赖就可以省略version标记了。 其他”Starters“只简单提供开发特定类型应用所需的依赖。由于正在开发web应用,我们将添加`spring-boot-starter-web`依赖-但在此之前,让我们先看下目前的依赖: ``` $ mvn dependency:tree [INFO] com.example:myproject:jar:0.0.1-SNAPSHOT ``` `mvn dependency:tree`命令可以将项目依赖以树形方式展现出来,你可以看到`spring-boot-starter-parent`本身并没有提供依赖。编辑`pom.xml`,并在`parent`节点下添加`spring-boot-starter-web`依赖: ``` <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> ``` 如果再次运行`mvn dependency:tree`,你将看到现在多了一些其他依赖,包括Tomcat web服务器和Spring Boot自身。