我正在尝试为我的 4 个微服务实施 Discovery First Bootstrap 方式。第一个是从 git 获取配置的配置服务器,第二个是 Eureka 服务器。当我运行 docker-compose up 时,我的配置服务器无法注册 eureka。我有:
请求执行错误。endpoint=DefaultEndpoint{ serviceUrl=' http://localhost:8761/ } 连接被拒绝
我的配置服务器
@EnableConfigServer
@EnableEurekaClient
@SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
Run Code Online (Sandbox Code Playgroud)
应用程序.yml
server:
port: 8888
spring:
cloud:
config:
server:
encrypt.enabled: false
git:
uri: https://github.com/Artuwok/artbook-config-repo/
searchPaths: userservice
username: Artuwok
password: Civilization1986
timeout: 10
force-pull: true
Run Code Online (Sandbox Code Playgroud)
引导程序.yml
spring:
application:
name: configserver
cloud:
config:
fail-fast: true
discovery.enabled: true
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl.defaultZone: http://localhost:8761/eureka/
Run Code Online (Sandbox Code Playgroud)
尤里卡级 …
我有一个希望打印值的代码示例。正如我在 countDownLatch.countDown(); 之后的 run 方法中所想的那样 被称为 CountDownLatch 应该达到零并且 main 方法应该终止,但它没有发生。我错过了什么吗?
public class ExecutorWithCountDownLatch {
public static void main(String[] args) throws InterruptedException {
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final CountDownLatch countDownLatch = new CountDownLatch(1);
executorService.execute(new ThreadCounter(countDownLatch));
countDownLatch.await(5, TimeUnit.SECONDS);
}
private static class ThreadCounter implements Runnable {
private CountDownLatch countDownLatch;
public ThreadCounter(CountDownLatch countDownLatch) {
this.countDownLatch = countDownLatch;
}
@Override
public void run() {
for (int i = 0; i <= 25; i++) {
System.out.println("printing numbers: " + i);
}
countDownLatch.countDown();
}
} …Run Code Online (Sandbox Code Playgroud)