Jhipster building docker图像错误与redis连接

Jhipster building docker图像错误与redis连接,jhipster,Jhipster,我是Jhipster社区的新手,开发平台看起来非常好! 但我在为我的本地发展树立码头工人形象方面遇到了一个问题 我成功地生成了jhipster应用程序,然后我继续阅读文档并尝试使用(maven)构建docker映像 我不断重复这个错误(大约10万次,之后停止并说构建失败) 我们清楚地看到:RedisConnectionException:无法连接到Redis服务器:localhost/127.0.0.1:6379 同时,我可以看到redis容器正在docker中运行,但没有端口6379,它在端口

我是Jhipster社区的新手,开发平台看起来非常好! 但我在为我的本地发展树立码头工人形象方面遇到了一个问题

我成功地生成了jhipster应用程序,然后我继续阅读文档并尝试使用(maven)构建docker映像

我不断重复这个错误(大约10万次,之后停止并说构建失败)

我们清楚地看到:
RedisConnectionException:无法连接到Redis服务器:localhost/127.0.0.1:6379

同时,我可以看到redis容器正在docker中运行,但没有端口6379,它在端口32789上(看起来像docker的默认可用端口)

我在windows 10上,有人已经有这个问题了


提前感谢

这是6.10.1中的一个例外。它将在即将发布的6.10.2版本(尚未发布)中修复。在此之前,您需要更改RedisTestContainerExtension实现

现在应该是这样的:

公共类RedisTestContainerExtension在回调之前实现{
private static AtomicBoolean start=新的AtomicBoolean(false);
私有静态通用容器redis;
@动态属性源
静态属性(DynamicPropertyRegistry注册表){
registry.add(“jhipster.cache.redis.server”,()->“redis://”+redis.getContainerIpAddress()+”:“+redis.getMappedPort(6379));
}
@凌驾
public void beforeAll(ExtensionContext ExtensionContext)引发异常{
如果(!started.get()){
redis=新的通用容器(“redis:6.0.4”)。具有公开端口(6379);
redis.start();
已启动。设置(true);
}
}
}
问题在于
DynamicPropertySource
,它只在测试类中工作,而不在junit扩展中工作。因此,您需要删除它,并设置一个系统属性,以使用容器中的正确端口覆盖redis连接,如下所示:

公共类RedisTestContainerExtension在回调之前实现{
private static AtomicBoolean start=新的AtomicBoolean(false);
私有静态GenericContainer redis=新的GenericContainer(“redis:6.0.4”)。具有公开端口(6379);
@凌驾
public void beforeAll(ExtensionContext ExtensionContext)引发异常{
如果(!started.get()){
redis.start();
System.setProperty(
“jhipster.cache.redis.server”,
“redis://”+redis.getContainerIpAddress()+“:”+redis.getMappedPort(6379)
);
已启动。设置(true);
}
}
}

您使用的是哪个版本的jhipster?为redis testcontainer设置属性时出现错误。@AtomFred我使用的是版本6.10.1,此版本受此错误影响?是。问题在于RedistTestContainerExtension,它使用动态属性,而动态属性只在测试类中工作。您需要更改beforeAll实现以设置系统属性。正确的代码如下:
/mvnw package -Pprod verify jib:dockerBuild
2020-08-24 15:48:55.693  WARN 8388 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jCacheCacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.CacheManager]: Factory method 'jCacheCacheManager' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManagerCustomizer' defined in class path resource [com/carcrypto/api/config/CacheConfiguration.class]: Unsatisfied dependency expressed through method 'cacheManagerCustomizer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jcacheConfiguration' defined in class path resource [com/carcrypto/api/config/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.cache.configuration.Configuration]: Factory method 'jcacheConfiguration' threw exception; nested exception is org.redisson.client.RedisConnectionException: Unable to connect to Redis server: localhost/127.0.0.1:6379
2020-08-24 15:48:55.698 ERROR 8388 --- [           main] o.s.boot.SpringApplication               : Application run failed