[英]Spring Boot with spring-boot-starter-web fails to compile in maven
I am using jdk1.7 and spring boot 1.4.2.Release.I created a brand new Spring boot project from start.spring.io. 我正在使用jdk1.7和spring boot 1.4.2.Release。我从start.spring.io创建了一个全新的Spring boot项目。 It compiled fine.
它编译良好。 I tried to add the below dependency for exposing a REST web service.
我试图添加以下依赖项以公开REST Web服务。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I get the below error: 我收到以下错误:
[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]
It takes the http://repo.spring.io/ext-release-local link which does not have jboss related files. 它带有http://repo.spring.io/ext-release-local链接,该链接没有jboss相关文件。
Please let me know if I am doing something wrong. 如果我做错了事,请告诉我。
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>
after that you need to run it with command mvn spring-boot:run
from the project directory 之后,您需要从项目目录使用命令
mvn spring-boot:run
运行它
I hope this time it will defenetly work only need to copy and pase this pom content to your pom file 我希望这一次它将不再使用,仅需要将此pom内容复制并插入到您的pom文件中
To build spring boot application from scratch you can follow the link 要从头开始构建Spring Boot应用程序,您可以点击链接
In my case, just adding the repository configuration to the pom.xml didn't work. 就我而言,仅将存储库配置添加到pom.xml中是行不通的。 I had to add the following code into /maven-installation-dir/conf/settings.xml file.
我必须将以下代码添加到/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>
I hope it helps someone. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.