我试图用基本的auth消耗一个宁静的ws.我没有将任何证书导入我的密钥库.当我使用chrome插件Advance Rest client测试它时(使用base64编码的基本身份验证用户名:pass).我可以看到回复.到现在为止还挺好.但是当我开发Java代码来使用这个ws时,我得到了SSL的失败:
org.springframework.web.client.ResourceAccessException: I/O error:
Received fatal alert: handshake_failure; nested exception is
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:377)
at test.Rest.main(Rest.java:37) Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果问题是因为我没有将证书导入我的密钥库,那么Java代码和插件都不应该一起工作.在这里,插件可以工作,但我的代码没有.是什么原因?我的代码有些不对劲?
贝娄是我的代码
RestTemplate restTemplate = new RestTemplate();
String plainCreds = "username:pass";
byte[] plainCredsBytes = plainCreds.getBytes(Charset.forName("US-ASCII") );
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
String base64Creds = new String(base64CredsBytes);
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic " + base64Creds);
ResponseEntity<String> response =
restTemplate.exchange("https://url",HttpMethod.GET,new …Run Code Online (Sandbox Code Playgroud) 我想通过HTTPS仅负载均衡器公开在Google容器引擎中运行的HTTP服务.
如何在入口对象中定义我HTTPS只想要负载均衡器而不是默认HTTP?
或者有没有办法HTTP从创建的负载均衡器中永久删除协议?当我添加HTTPS协议然后删除HTTP协议时,HTTP平台几分钟后重新创建.
入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myapp-ingress
spec:
backend:
serviceName: myapp-service
servicePort: 8080
Run Code Online (Sandbox Code Playgroud) 我想删除多个实体属性的实体?
我知道如何使用JPA query(@Query注释).
是否有可能使用它derived query?如何命名这种方法JpaRepository?
我试图了解 ProxySelector 类的工作原理。我当前的代码如下所示:
URI uri = new URI("http://google.com");
proxySelector.select(uri);
Run Code Online (Sandbox Code Playgroud)
据我了解,调用proxySelector.select(uri);此函数时应该返回相应 URI 的代理列表。但我不知道如何为每个 URI 设置代理。
我知道我可以使用该setDefault()方法设置默认代理,但据我了解,这将设置系统范围的代理,而不是特定URI.
我可能在这里遗漏了一些基本点,但如何为网址 A (例如http://google.com)设置一个代理并为网址 B (例如http://ebay.com)设置一个不同的代理,然后让系统每次连接到相应的url时都会自动选择正确的代理?
除了kubectl edit在Kubernetes中删除注释之外,还有其他方法吗?
我不喜欢的交互性kubectl edit。我更喜欢脚本中可用的东西。
我想创建 Spring 方面,它将通过自定义注释注释的方法参数设置为由 URI 模板中的 id 标识的特定类的实例。路径变量名是注解的参数。与 Spring@PathVariable所做的非常相似。
所以控制器方法看起来像:
@RestController
@RequestMapping("/testController")
public class TestController {
@RequestMapping(value = "/order/{orderId}/delete", method = RequestMethod.GET)
public ResponseEntity<?> doSomething(
@GetOrder("orderId") Order order) {
// do something with order
}
}
Run Code Online (Sandbox Code Playgroud)
而不是经典:
@RestController
@RequestMapping("/testController")
public class TestController {
@RequestMapping(value = "/order/{orderId}/delete", method = RequestMethod.GET)
public ResponseEntity<?> doSomething(
@PathVariable("orderId") Long orderId) {
Order order = orderRepository.findById(orderId);
// do something with order
}
}
Run Code Online (Sandbox Code Playgroud)
注释来源:
// Annotation
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface GetOrder{
String value() default ""; …Run Code Online (Sandbox Code Playgroud) 根据Spring Cloud Kubernetes文档,为了在启用 RBAC 的 Kubernetes 发行版中发现服务/pod:
您需要确保使用 spring-cloud-kubernetes 运行的 pod 可以访问 Kubernetes API。对于您分配给部署/pod 的任何服务帐户,您需要确保它具有正确的角色。例如,您可以
cluster-reader根据您所在的项目为您的默认服务帐户添加权限。
什么是cluster-reader发现服务/pod 的权限?
我收到的错误是:
io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: https://x.x.x.x/api/v1/namespaces/jx-staging/services.
Message: Forbidden!Configured service account doesn't have access.
Service account may have been revoked. services is forbidden:
User "system:serviceaccount:jx-staging:default" cannot list services in the namespace "jx-staging"
Run Code Online (Sandbox Code Playgroud) 我想使用 http GET 调用 RestTemplate 并检索状态代码和重定向的 url(如果有的话)。
如何实现这一目标?
我|在准备探针命令中传递管道字符时遇到问题。
我想要一个探测命令:
curl --silent http://localhost:8080/actuator/health | grep --quiet -e '^{\"status\"\:\"UP\".*}$'
这是我定义探针的方式:
# kubectl get pod my_pod -o yaml
readinessProbe:
exec:
command:
- curl
- --silent
- http://localhost:8080/actuator/health
- '|'
- grep
- --quiet
- -e
- '''^{\"status\"\:\"UP\".*}$'''
Run Code Online (Sandbox Code Playgroud)
就绪探测失败并显示以下消息:
就绪探测失败:curl:选项 --quiet:未知 curl:尝试“curl --help”或“curl --manual”以获取更多信息
在没有管道字符的情况下执行命令时可以重现错误|:
curl --silent http://localhost:8080/actuator/health grep --quiet -e '^{\"status\"\:\"UP\".*}$'
出于某种原因,Kubernetes 不会解释管道。
你能帮我在部署中传递管道吗?
是否有一个Java框架来存储Redis中的关系数据?用于简单用例的东西,例如:
如何使用 Spring Boot 从 YAML 属性将日期值绑定到 Java 映射键中?
YAML 属性文件:
settings:
calendar:
2018-06-04: 2018-06-25
2018-07-15: 2018-07-20
Run Code Online (Sandbox Code Playgroud)
属性类:
calendar地图的目的是将一个日期转换为另一个日期。
@ConfigurationProperties(prefix = "settings")
public class CalendarSettings {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Map<LocalDate, LocalDate> calendar = new HashMap<>();
public Map<LocalDate, LocalDate> getCalendar() {
return calendar;
}
public void setCalendar(
Map<LocalDate, LocalDate> calendar) {
this.calendar = calendar;
}
}
Run Code Online (Sandbox Code Playgroud)
通过此设置,我收到以下异常:
Property: settings.null
Value: 2018-06-04
Reason: Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'null';
nested exception is …Run Code Online (Sandbox Code Playgroud) 有两个服务。我正在使用 Netflix 堆栈 [Eureka/zuul]。
当我运行一个用户服务实例时,一切正常,但是当我在另一台服务器上运行另一个实例时,我遇到了下面提到的错误并且请求 [login oauth] 失败。
我想扩展使用 spring oauth 的 USER-SERVICE。
处理错误:InvalidGrantException,无效授权码:Q1j7Hs 06:24:17.253 [http-nio-8081-exec-2] INFO ossopeTokenEndpoint - 处理错误:InvalidGrantException,无效授权码:w9uvl1
任何线索或建议将不胜感激。
spring ×5
java ×4
kubernetes ×4
resttemplate ×2
architecture ×1
aspectj ×1
http-proxy ×1
nosql ×1
oauth ×1
openshift ×1
proxy ×1
redirect ×1
redis ×1
spring-aop ×1
spring-boot ×1
spring-cloud ×1
spring-data ×1
spring-mvc ×1
ssl ×1
uri ×1
url ×1
yaml ×1