问题描述
我在Window和Mac的STS(Spring工具套件)上创建了spring boot项目(Spring starter项目)。这是我的 pom.xml
:
I created spring boot project(Spring starter project) on STS(Spring tool suit), both of Window and Mac. Here is my pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
在Mac上缺少某些依赖项层次结构。
Some of the dependency hierarchies are missing on Mac.
示例:
休眠验证器
- validation-api(在Mac上丢失)
- jboss-loggin(在Mac上丢失)
- 同学(在Mac上丢失)
我需要Mac上的jar而不修改pom.xml。
我想我想念一些环境Mac。
I need that jars on Mac without modifying pom.xml.I think I miss some environment Mac.
我2天前买了Mac。这是我的第一台Mac。
And I bought Mac 2 days ago. It's my first Mac.
推荐答案
如果要使用Hibernate Validator,则需要将其作为显式依赖项包括在内:
If you want to use Hibernate Validator, you need to include it as explicit dependency:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
注意,我们没有指定版本,因为Spring Boot会处理它。
Notice we don't specify version as Spring Boot will take care of it.
其他选项是使用:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
关于Windows / MacOS特定的问题,这是一种误解。您需要我提到的依赖项。如果包含它们,则在两个平台上都将以相同的方式工作。
Concerning your Windows/MacOS specific problems, it is some kind of misunderstanding. You need dependencies I mentioned. If you include them, it will work the same way on both platforms.
这篇关于在Mac上缺少spring-boot-starter-web hibernate-validator依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!