使用STS的Spring Boot Maven项目构建错误

我在STS中创建一个新的Spring启动项目时收到以下错误消息

project build error: Non-resolvable parent POM for com.test:security:1.3.8-SNAPSHOT: Failure to transfer 
 org.springframework.boot:spring-boot-starter-parent:pom:1.3.8.RELEASE from https://repo.maven.apache.org/maven2 was 
 cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates 
 are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.3.8.RELEASE 
 from/to central (https://repo.maven.apache.org/maven2): connect timed out and 'parent.relativePath' points at no local POM

的pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
**<groupId>com.test</groupId>
<artifactId>security</artifactId>
<version>1.3.8-SNAPSHOT</version>
<packaging>jar</packaging>

        <name>security</name>
        <description>Demo project for Spring Boot</description>

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.3.8.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-security</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>** 

对于每个Spring启动项目,我收到上述错误消息 .

回答(2)

2 years ago

您应该将Spring引导父依赖项更新为最新的realease 1.5.3:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
</dependency>

2 years ago

您使用的是 Maven 2 还是 Maven 3.x

根据文档, Spring Boot 与Apache Maven 3.2 或更高版本兼容(https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#getting-started-maven-installation