带有Spring-Boot-Starter-Web的弹簧靴未能在Maven中编译



我正在使用JDK1.7和Spring Boot 1.4.2.release.i从Start.spring.io创建了一个全新的Spring Boot Project。它编译了。我尝试添加以下依赖性以公开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相关的文件。

请告诉我,如果我做错了什么。

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 file

要从头开始构建Spring Boot应用程序,您可以按照链接

构建。

在我的情况下,只需在pom.xml中添加 repository 配置。我必须将以下代码添加到/maven-installation-dir/conf/settings.xml file。

<mirror>
    <id>central-proxy</id>
    <name>central-proxy</name>
    <url>http://corporate-intranet/repo/url</url>
    <mirrorOf>central</mirrorOf></mirror>

我希望它对某人有帮助。

最新更新