【问题标题】:Can't add spring cloud configuration server to spring app无法将spring cloud配置服务器添加到spring app
【发布时间】:2021-11-25 04:48:26
【问题描述】:

伙计们,我刚刚开始了一个新的 spring 项目,它将为微服务架构应用程序保存配置服务器,这是我从 spring 初始化程序获得的 pom 文件

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.ramsey.eagleeye</groupId>
    <artifactId>confsvr</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>confsvr</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
        <spring-cloud.version>2020.0.4</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

但是,一旦我尝试下载依赖项,就会在 Intellij 中收到此错误 Cannot resolve org.springframework:spring-core:5.3.10,有人知道它有什么问题吗?或者我应该如何解决?

【问题讨论】:

  • 命令行会发生什么?
  • @spencergibb [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project confsvr: Fatal error compiling: error: invalid target release: 17 -&gt; [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  • @spencergibb 这就是我得到的
  • 您使用的是 JDK 17 吗?看起来不像那样...mvn --version 打印出来的是什么...请更新您的帖子..
  • @khmarbaise 哦,实际上我没有注意到我没有将 java home 变量设置为 17,它是 16,但现在已修复,谢谢提醒我:3

标签: spring maven spring-cloud spring-cloud-config


【解决方案1】:

问题只是我没有将 JAVA_HOME 变量更新到 JDK 17,它仍然在 16 上。

【讨论】:

    猜你喜欢
    • 2018-08-24
    • 2017-09-07
    • 2017-07-25
    • 2023-03-24
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2016-09-12
    • 2020-09-27
    相关资源
    最近更新 更多