java - spring cloud config客户端立即启动和停止
问题描述
我正在尝试使用此链接构建基本的 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"));
}
}
下面是 bootstrap.properties 文件
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
解决方案
推荐阅读
- html - 如何阻止音频元素重叠导航
- visual-studio-code - 防止 VS Code 在另存为时将光标移动到文件开头
- reporting-services - 使用 IIF() 函数的 SSRS 报表生成器表达式无法正确评估包含“<”和“>”字符的条件
- python - VTK 检查多数据点对象的交叉点
- python-3.x - 我对海龟颜色脚本有一些问题
- javascript - 从包含类对象的数组中删除特定项目
- fetch - 如何使用 BigCommerce 的 Storefront Cart API 将商品添加到现有购物车?
- reactjs - ReactJS:如何以编程方式将用户重定向到另一个页面?
- java - 使用 Dozer 将字符串数组映射到 POJO
- git - 是否可以将分离和修改的文件夹重新连接到 Git 存储库?