我运行一个名为"redis"的docker容器.我想使用"redis"容器redis服务,但我不能ping容器!
如图所示,我的"redis"容器的IP地址是172.17.0.15,但我无法连接到它.
我想使用redis服务.我的配置有什么问题?
在我的 Java spring 应用程序中,我有
public class BinarySearchImpl {
@Autowired
@Qualifier("Quick")
SortAlgorithem sorter;
Log log=LogFactory.getLog(BinarySearchImpl.class);
public BinarySearchImpl(SortAlgorithem sorter) {
log.info("Binary Search Bean is created");
this.sorter=sorter;
}
Run Code Online (Sandbox Code Playgroud)
SortAlgorithem 是一个接口,它使我的应用程序松散耦合:
public interface SortAlgorithem {
public int[] sort(int[] arrayNumbers);
}
Run Code Online (Sandbox Code Playgroud)
然后这个接口有2个实现。一种是BubbleSort:
@Component
@Qualifier("Bubble")
public class BubbleSort implements SortAlgorithem {
Log log=LogFactory.getLog(BubbleSort.class);
public int[] sort(int[] numbers) {
log.info("Bubble sort is called");
return numbers;
}
}
Run Code Online (Sandbox Code Playgroud)
另一个是QuickSort:
@Component
@Qualifier("Quick")
//@Primary
public class QuickSort implements SortAlgorithem{
Log log= LogFactory.getLog(QuickSort.class);
public int[] sort(int[] numbers) …Run Code Online (Sandbox Code Playgroud) 我们有一个Spring Boot应用程序需要将消息发送到远程HornetQ消息代理上可用的队列.我看到Spring Boot在嵌入模式下支持HornetQ.但是,我只能在我的Boot应用程序的application.properties上设置一组spring.hornetq.*属性.应用程序必须使用核心网桥(存储和转发),该网桥在hornetq-configuration.xml文件中配置.
问:我需要做些什么才能使Spring Boot提供的HornetQ嵌入式实例使用我创建的hornetq-configuration.xml文件?
我试图将docker镜像发布到私有存储库,但我无法弄清楚我认为将SSL证书放在Windows机器上的位置.
根据此页面 https://docs.docker.com/engine/security/certificates/,证书应该放在/etc/docker/certs.d/HOSTNAME目录中.这显然不是Windows路径.但是,当我运行docker终端并输入cd/etc时,它确实将我带到了一个工作目录.
经过一番调查后,我发现它将转到C:\ Program Files\Git\etc,所以我在该路径下创建了一个docker\certs.d\docker-registry.lan(docker-registry.lan是我们的内部注册表)目录.然后我用docker-machine stop,docker-machine start命令重启docker机器.
但是当我尝试推送时,我收到的错误是x509:由未知权限签署的证书
这个密钥适用于通过linux执行此操作的其他人,因此我知道密钥很好.我认为问题在于我没有将密钥存储在正确的位置.
我为密钥尝试了一堆不同的loactions,但似乎都没有.这必须是一个我很想念的简单修复.解决这个问题的人可以帮助我吗?
谢谢
有什么区别:
当我尝试使用 openfeign 遵循教程时发现了这个问题@FeignClient(name=...)。不过我用的是feign,不是openfeign,这个注解也不一样。
这不是同一件事吗?
我正在使用 Kibana Discover 创建已保存的搜索。在屏幕上我可以手动选择时间范围(默认为“最后 15 分钟”)。如果我选择“过去 24 小时”并刷新搜索,则效果很好。但是,当我保存搜索时,时间范围信息不会保存。每当我打开 Kibana Discover 并打开我保存的搜索时,时间范围始终是默认值(最近 15 分钟)。
我尝试在 KQL 查询中添加不同的条件(如下),但无济于事。:^(
and @timestamp >= "now-24h"
and @timestamp >= now-24h
and timestamp >= "now-24h"
and @timestamp >= "now-1d/d"
etc.
Run Code Online (Sandbox Code Playgroud)
我还尝试使用该@timestamp字段“添加过滤器”。唯一可用的运算符有:is not, is one of, is not one of, is between, is not between, exists, does not exist。
所以,我尝试了between now-24h并且now。然而,没有结果符合标准。
但是,如果我手动将时间范围更改为“过去 30 天”,那么我的过滤器就会起作用!
如何在我的 KQL 保存的搜索中包含时间范围(例如过去 24 …
我有一个REST调用接受一个JSON对象,比方说,一个人.在我创建此对象(验证并保存到数据库)后,我需要返回新创建的JSON对象.
我认为标准做法是返回201 Accepted而不是立即返回对象.但我的应用程序需要立即新创建的对象.
我有一个控制器方法,它接受一个POST调用,调用一个服务类,然后调用一个使用Hibernate来创建对象的DAO.一旦它保存到数据库,我正在调用另一个控制器方法,该方法获取人员的ID并返回对象.
我的问题是,这是更好的方法吗?这是调用另一个Controller方法来获取新创建的对象.或者POST调用本身应该返回Object.
主要问题是: 调用另一种方法需要往返,我猜这是一种矫枉过正.(服务- > DAO-> Hibernate->数据库).相反,我认为我应该在相同的调用(从处理POST的方法)中保存后立即从数据库中获取对象.
这里的架构标准是什么?
我想根据响应对象错误动态返回 HTTPStatus 代码,如 400、400、404 等。我被提到了这个问题 -使用 spring 3 restful以编程方式更改 http 响应状态,但它没有帮助。
我有一个带有@ExceptionHandler方法的控制器类
@ExceptionHandler(CustomException.class)
@ResponseBody
public ResponseEntity<?> handleException(CustomException e) {
return new ResponseEntity<MyErrorResponse>(
new MyErrorResponse(e.getCode(), ExceptionUtility.getMessage(e.getMessage())),
ExceptionUtility.getHttpCode(e.getCode()));
}
Run Code Online (Sandbox Code Playgroud)
ExceptionUtility是一个类,我在其中使用了上面使用的两种方法(getMessage和getCode)。
public class ExceptionUtility {
public static String getMessage(String message) {
return message;
}
public static HttpStatus getHttpCode(String code) {
return HttpStatus.NOT_FOUND; //how to return status code dynamically here ?
}
}
Run Code Online (Sandbox Code Playgroud)
我不想检查 if 条件并相应地返回响应代码,有没有其他更好的方法来做到这一点?
有2个配置,在不同的jar文件中我想控制拦截器注册的顺序.一个拦截器可能依赖于另一个拦截器的数据集.
我在addInterceptors方法上尝试了@Order.
@Configuration
public class PipelineConfig extends WebMvcConfigurerAdapter {
@Autowired
@Qualifier("Audit")
HandlerInterceptor auditInterceptor;
public PipelineConfig() {
}
@Order(2)
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this.auditInterceptor);
}
}
Run Code Online (Sandbox Code Playgroud)
和
@Configuration
public class ExecutionPipelineConfig extends WebMvcConfigurerAdapter {
@Autowired
@Qualifier("ExecutionContext")
HandlerInterceptor executionContextInterceptor;
public ExecutionPipelineConfig() {
}
@Order(1)
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(this.executionContextInterceptor);
}
}
Run Code Online (Sandbox Code Playgroud) 在微服务架构中,我们通常有两种微服务通信的方式。假设服务 A 需要从服务 B 获取信息。第一个选项是远程调用,通常通过 HTTPS 同步,因此服务 A 查询服务 B 托管的 API。
第二种选择是采用事件驱动架构,其中服务 B 的状态可以以异步方式由服务 A 发布和消费。使用此模型,服务 A 可以使用来自服务 B 的事件的信息更新其自己的数据库,并且所有查询都在此数据库中本地进行。这种方法的优点是可以更好地分离微服务,从开发到运营。但它有一些与数据复制相关的缺点。
第一个是磁盘空间的高消耗,因为相同的数据可以驻留在需要它的微服务的数据库中。但在我看来,第二个最糟糕:如果服务 B 不能按需要快速处理其订阅,或者在服务 B 上创建它的同时它不能用于服务 A,则数据可能会变得陈旧,因为模型的最终一致性。
假设我们使用 Kafka 作为事件中心,其主题配置为使用 7 天的数据保留期。当服务 B 发布其状态时,服务 A 保持同步。两周后,新服务 C 部署完毕,其数据库需要使用服务 B 拥有的所有信息进行充实。由于最旧的事件已经消失,我们只能从 Kafka 主题中获取部分信息。我的问题是我们可以使用哪些模式来实现此微服务的数据库丰富(除了要求服务 B 将其所有当前状态重新发布到事件中心)。
event-driven eventual-consistency database-replication apache-kafka microservices
java ×3
docker ×2
spring ×2
spring-mvc ×2
apache-kafka ×1
boot2docker ×1
event-driven ×1
feign ×1
hornetq ×1
interceptor ×1
json ×1
kibana ×1
openfeign ×1
rest ×1
spring-boot ×1
standards ×1
windows ×1