如何通过Spring Boot管理控制台更改属性值?

时间:2018-03-12 13:35:41

标签: spring spring-boot properties spring-boot-admin

我有一个Spring Boot管理控制台的Spring启动应用程序: SBA

它显示DetailsMetrics等。还有一个Environment标签。

  1. 是否可以通过Environment选项卡更改application.properties值?
  2. 如果我向属性键添加新值并按Update environment按钮,则应用程序中没有任何更改。为什么?我需要做任何额外的设置吗?
  3. 谢谢。

    更新

    我对POM的依赖:

    <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-actuator-docs</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-mail</artifactId>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-client</artifactId>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-server</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-configuration-processor</artifactId>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
    
    
            <dependency>
                <groupId>com.microsoft.sqlserver</groupId>
                <artifactId>sqljdbc4</artifactId>
                <version>4.2</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.5</version>
            </dependency>
    
    
            <dependency>
                <groupId>org.firebirdsql.jdbc</groupId>
                <artifactId>jaybird</artifactId>
                <version>2.2.5</version>
            </dependency>
    
    
    
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.5</version>
            </dependency>
    
    
            <dependency>
                <groupId>com.protectimus.api.sdk</groupId>
                <artifactId>api-sdk-java</artifactId>
                <version>1.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>4.0</version>
            </dependency>
    
    
    
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-dbcp2</artifactId>
                <version>2.1.1</version>
                <exclusions>
                    <exclusion>
                        <artifactId>commons-logging</artifactId>
                        <groupId>commons-logging</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
    
    
            <dependency>
                <groupId>me.moocar</groupId>
                <artifactId>logback-gelf</artifactId>
                <version>0.3</version>
            </dependency>
    
    
    
         <!-- <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter</artifactId>
           </dependency>-->
    
    
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web-services</artifactId>
            </dependency>
    
    
        </dependencies>
    
        <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-dependencies</artifactId>
                <version>${spring-boot-admin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    

1 个答案:

答案 0 :(得分:1)

我已经设置了一些测试环境...

使用SBA,我更新了一个环境。.一个小的hello-world REST端点显示了新值...但是在SBA中是旧值。

也许您的bean需要一个@RefreshScope批注?