Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring未知属性';spring.cloud.config.server';_Java_Spring_Eclipse_Spring Boot - Fatal编程技术网

Java Spring未知属性';spring.cloud.config.server';

Java Spring未知属性';spring.cloud.config.server';,java,spring,eclipse,spring-boot,Java,Spring,Eclipse,Spring Boot,我正试图在我的spring项目中连接到git配置服务器,在EclipseIDE中遵循下面的示例 但是,由于eclipse无法识别bootstrap.yml(未知属性“spring.cloud.config.server”)中的服务器属性,因此我在解决所需属性时遇到了问题 我已经包含了上面示例中列出的所有依赖项(SpringCloud依赖项、SpringCloudStarter配置、SpringBootStarter测试),但是我仍然收到错误 何时可以使用此属性有限制吗?或者是否需要额外的依赖关

我正试图在我的spring项目中连接到git配置服务器,在EclipseIDE中遵循下面的示例

但是,由于eclipse无法识别bootstrap.yml(未知属性“spring.cloud.config.server”)中的服务器属性,因此我在解决所需属性时遇到了问题

我已经包含了上面示例中列出的所有依赖项(SpringCloud依赖项、SpringCloudStarter配置、SpringBootStarter测试),但是我仍然收到错误

何时可以使用此属性有限制吗?或者是否需要额外的依赖关系

提前谢谢


更新:我只需要添加一个SpringCloudStarter配置服务器依赖项。不知道为什么它没有被其他人拉进来,但这确实起了作用。谢谢大家的帮助。

下面是一个小示例,说明如何使用spring云配置使用它:

bootstrap.yml

因此,假设您有一个git repo,它必须包含一个文件OpscI2aClient-sheba.yml

该文件只是一个简单的spring引导配置文件,但不应包含活动的概要文件条目。 就是这样

我想澄清一下: 假设名为OpscI2aClient的应用程序有两个配置文件dev和prod, 您的git配置报告实际上应该包含两个文件: 1.OpscI2aClient-dev.yml 2.OpscI2aClient-prod.yml

希望这有帮助

我只是在添加POM,您可能会在其中找到一些提示

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <project.scm.id>opsc-scm-server</project.scm.id>
    <java.version>1.8</java.version>
    <slf4j.version>1.7.2</slf4j.version>
    <logback.version>1.1.3</logback.version>
    <spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</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-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </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>

UTF-8
UTF-8
opsc scm服务器
1.8
1.7.2
1.1.3
Edgware.RELEASE
org.springframework.boot
spring启动程序父级
1.5.9.1发布
org.springframework.cloud
spring云配置服务器
朱尼特
朱尼特
测验
org.springframework.boot
弹簧起动试验
测验
org.springframework
弹簧试验
测验
org.springframework.boot
spring引导配置处理器
符合事实的
org.slf4j
slf4j api
回写
回归经典
回写
回溯堆芯
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧靴起动器执行器
共中心
spring启动管理启动客户端
1.5.6
org.jolokia
约洛基亚岩芯
org.springframework.cloud
spring云依赖关系
${spring cloud.version}
聚甲醛
进口

首先,是否只是Eclipse看不到服务器,您可以从命令行运行它而不出错? 如果只是Eclipse,那么可能是错误的缩进或制表符。Eclipse有时并不那么聪明

  • 尝试将其全部设置为plain application.properties文件
  • 尝试从命令行运行它
另外,我认为您必须为git+加密或不加密添加凭据部分

下面是在STS Eclipse中运行良好的YML的有效示例:

谢谢。这就是我试图做的,但是uri从未被提取,因为eclipses认为“spring.cloud.config.server”是未知的。它不认为这是一个有效的属性。我使用STS(SpringToolSuite)进行开发,它在SpringBoot属性中获得了更好的行为。现在,尽管eclipse没有获取该属性,但运行应用程序时是否存在异常?它会加载你的配置吗?如果这样做了,并且Eclipse没有提取到您的所有问题和属性,那么您可以自己将其添加到项目的resources/META-INF/addition-spring-configuration-metadata.json中,您在哪里看到标题中的错误?您能够从命令行运行项目吗?不,即使我尝试运行它,它也不会获取uri属性。它默认返回到localhost。问题是eclipse/spring无法识别服务器级别的属性是否有效。同样,如果从命令提示符编译并运行应用程序,情况是否相同?
spring:
  profiles:
    # this will tell spring to pick the correct profile file
    active: sheba

  # u must specify your application name for it to be found in the git repository!    
  application:
    name: OpscI2aClient

  # now we telling our git client where to locate our config files
  cloud:
    config:
      server:
        bootstrap: true

        git:
          # this the full uri to our repository where the config file
          # wich its name is ApplicationName-profileName.yml
          # are found
          uri: https://some.company.git.com/config/config-repo.git
          username: someGitUserName
          password: thePasswordOfTheGitUser
          # clone the whole config repository on startup
          the whole files in the repository are cloned!
          clone-on-start: true
          # this tell spring the name of the local repository directory
          # which in this case it shall create a directory called git_local
          relatively to where the application started
          basedir:
            git_local
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <project.scm.id>opsc-scm-server</project.scm.id>
    <java.version>1.8</java.version>
    <slf4j.version>1.7.2</slf4j.version>
    <logback.version>1.1.3</logback.version>
    <spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</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-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-core</artifactId>
    </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>