设置Spring-Boot Maven项目

时间:2018-10-29 12:32:40

标签: spring-mvc spring-boot maven-3 spring-boot-maven-plugin

我正在尝试从Spring Initilizr配置Spring-Boot项目。
依赖关系-> kafka,web

当我导入该项目时,在行

的pom.xml中出现错误
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Project build error: Non-resolvable parent POM for com.mobicule.kafkaexample:Spring-Producer:0.0.1-SNAPSHOT: Cannot 
 access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.springframework.boot:spring-boot-
 starter-parent:pom:2.0.6.RELEASE has not been downloaded from it before. and 'parent.relativePath' points at no local POM

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.mobicule.kafkaexample</groupId>
    <artifactId>Spring-Producer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Spring-Producer</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.6.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.kafka</groupId>
            <artifactId>spring-kafka</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>

在我的首选项下 已检查“嵌入式”安装。这会引起任何问题吗?
我还需要单独在Eclipse中进行Maven安装才能运行此项目吗?

请指导我,因为我无法理解任何行家错误

1 个答案:

答案 0 :(得分:0)

您处于离线模式。 看到异常

  

以离线模式访问中心(https://repo.maven.apache.org/maven2)和工件org.springframework.boot:spring-boot-    starter-parent:pom:2.0.6.RELEASE尚未从其下载。

您使用什么IDE?

编辑:在Eclipse中转到:窗口/首选项/ Maven->第一个复选框将Maven设置为脱机模式。检查是否已选择。如果选择->取消选择,然后尝试重新构建(全新安装)