有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaSpring云配置客户端立即启动和停止

我正在尝试使用这个link构建基本的spring boot云配置服务器和客户端应用程序
配置服务器启动时没有任何问题,但当我启动配置客户端时,它会启动,然后立即停止。它还可以根据日志访问配置服务器,但有些可疑之处。我也尝试了debug=true,但是没有特定的日志

下面是ConfigClient类

package com.consul.client.ConsulClient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

@SpringBootApplication
public class ConsulClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsulClientApplication.class, args);
    }

    @Autowired
    public void setEnv(Environment e) {
        System.out.println(e.getProperty("msg"));
    }

}

下面是引导程序。属性文件

server.port=8081
spring.cloud.config.uri=http://localhost:9081
spring.application.name=client-config
debug=true
management.security.enabled=false

启动日志如下所示

2020-03-23 00:09:37.048  INFO 1166 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9081
2020-03-23 00:09:38.154  INFO 1166 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=client-config, profiles=[dev], label=null, version=14a9dd2ad6b13bb2215de9f0945f48dc15e2f10e, state=null
2020-03-23 00:09:38.155  INFO 1166 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/jagginarendra/configserver/client-config-dev.properties'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/jagginarendra/configserver/client-config.properties'}]
2020-03-23 00:09:38.164  INFO 1166 --- [           main] c.c.c.C.ConsulClientApplication          : The following profiles are active: dev
2020-03-23 00:09:38.470  INFO 1166 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=9f0269c4-90eb-309e-8c49-d7fc7be3daa5
this is dev enc
2020-03-23 00:09:38.600  INFO 1166 --- [           main] c.c.c.C.ConsulClientApplication          : Started ConsulClientApplication in 7.314 seconds (JVM running for 7.802)

Process finished with exit code 0

共 (0) 个答案