我正在使用jdk1.7和spring boot 1.4.2.Release.I从start.spring.io创建了一个全新的Spring启动项目。它汇编得很好。我尝试添加以下依赖项来公开REST Web服务。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
我收到以下错误:
[ERROR] Failed to execute goal on project demo: Could not resolve
dependencies for project com.example:demo:jar:0.0.1-SNAPSHOT: Failed to
collect dependencies at org.springframework.boot:spring-boot-starter-
web:jar:1.4.2.RELEASE -> org.hibernate:hibernate-validator:jar:5.2.4.Final:
Failed to read artifact descriptor for org.hibernate:hibernate-
validator:jar:5.2.4.Final: Could not transfer artifact
org.jboss.shrinkwrap:shrinkwrap-bom:pom:1.2.2 from/to spring-ext
(http://repo.spring.io/ext-release-local/): repo.spring.io: Unknown host
repo.spring.io -> [Help 1]
它需要http://repo.spring.io/ext-release-local链接,它没有jboss相关文件。
如果我做错了,请告诉我。
答案 0 :(得分:3)
Your pom should look like this
<?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>jar</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.4.2.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-data-rest</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-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>
之后,您需要使用项目目录
中的命令mvn spring-boot:run
运行它
我希望这次它只需要复制并将这个pom内容复制到你的pom文件中
要从头开始构建Spring启动应用程序,您可以按照link
进行操作答案 1 :(得分:0)
对于我来说,仅将存储库配置添加到pom.xml中是行不通的。我必须将以下代码添加到 /maven-installation-dir/conf/settings.xml 文件中。
<mirror>
<id>central-proxy</id>
<name>central-proxy</name>
<url>http://corporate-intranet/repo/url</url>
<mirrorOf>central</mirrorOf></mirror>
我希望它能对某人有所帮助。