我正在一个我找到的网站上学习Springboot教程。该站点告诉我们向我们的pom.xml文件添加各种依赖项。我通过Spring添加了web和thymeleaf依赖项。实际上,我意识到我忘了添加安全性依赖项。当我试图编辑代码并通过键入以下内容添加安全性依赖项时:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
发布于 2019-08-23 10:09:15
您应该要么继承您的项目从spring-boot-starter-parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
</parent>
父项目提供以下特性:
<version>
pom
**.**中使用时省略针对这些依赖项的标记。repackage
的执行。application.properties
和application.yml
的合理资源筛选,包括特定于配置文件的文件(例如,application-dev.properties
和application-dev.yml
)或使用 spring-boot-dependencies
BOM表
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
当您不想从spring-boot-starter-parent
POM继承时,使用BOM是一种方法。您可能需要使用自己的企业标准父级,或者您可能更愿意显式声明所有Maven配置。您仍然可以保留依赖关系管理的好处,而不是插件管理。
这两种解决方案都允许您省略Spring依赖项的版本。
https://stackoverflow.com/questions/57599254
复制相似问题