Spring-cloud-config: "/env" not work at boot 2.0.0.RELEASE & cloud config 2.0.0.M9

Created on 29 Mar 2018  ·  6Comments  ·  Source: spring-cloud/spring-cloud-config

Question:
Description: "/env" not work
Springboot version: 2.0.0.RELEASE
SpringCloudConfig version: cloud config 2.0.0.M9
Java version: 1.8

Detail:
1.When My IntelliJ 14 Run Rest Client ==> Get http://localhost:8080/env I got 404
{"timestamp":"2018-03-29T09:49:56.148+0000","status":404,"error":"Not Found","message":"No message available","path":"/env"} ,
Though, My program had read the configfile successfully, I just can't get vars by "/env"
2.When I use springboot 1.5.9.Release and cloud version Dalston.RELEASE everything goes well
3.Here is my 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>LS12.08</groupId>
    <artifactId>gms-ccis</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>mon-ccis</name>
    <description>Monitor of CCIS</description>

    <repositories>
        <repository>
            <id>paas</id>
            <name>CMB Paas</name>
            <url>http://99.12.154.123/artifactory/libs-release/</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>milestone</id>
            <name>ART-SEV01KF-releases</name>
            <url>http://99.12.154.123/artifactory/spring-milestone</url>
        </repository>

        <repository>
            <id>ART-SEV01KF</id>
            <name>ART-SEV01KF-snapshots</name>
            <url>http://99.12.154.123/artifactory/third-cmb-snapshot-local</url>
        </repository>
    </repositories>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.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>LS12</groupId>
            <artifactId>Channel</artifactId>
            <version>0.0.6-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>LS12</groupId>
            <artifactId>Monitor-Elastic</artifactId>
            <version>0.0.3-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</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>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.46</version>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
            <version>5.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-config</artifactId>
                <version>2.0.0.M9</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Most helpful comment

Thank you very much @ryanjbaxter , after I add endpoint config /actuator/env works!
Here is part of my bootstrap config:

management:
  endpoint:
    env:
      enabled: true    (must)
  endpoints:
    web:
      exposure:
        include: env   (must)

It looks like the doc should be updated ==>http://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.0.0.M9/single/spring-cloud-config.html
Thanks a lot !

All 6 comments

try http://localhost:8080/management/env

@gitlabbin thx,but /management/env still not working

@ryanjbaxter thx i read the doc too and try /actuator/env too,but still not working,have you tried this?i create a clean project only to test this config ,but still can not get my env,change to the 1.x boot and the matched cloud works。but due to other compatible problem ,i cannot use 1.x,help!

Check out and the exposing and enabling endpoints sections in the spring boot docs https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-exposing-endpoints

If that still doesnt work provide a complete project and we will take a look

Thank you very much @ryanjbaxter , after I add endpoint config /actuator/env works!
Here is part of my bootstrap config:

management:
  endpoint:
    env:
      enabled: true    (must)
  endpoints:
    web:
      exposure:
        include: env   (must)

It looks like the doc should be updated ==>http://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.0.0.M9/single/spring-cloud-config.html
Thanks a lot !

Was this page helpful?
0 / 5 - 0 ratings