Number[][] intArray = new Integer[][]{ {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
double[][] doubleArray = Arrays.stream(intArray)
.forEach(pArray -> Arrays.stream(pArray)
.mapToDouble(d ->d.doubleValue())
.toArray())
.toArray();
Run Code Online (Sandbox Code Playgroud)
我想将Number [] []转换为double [] [].上面的lambda不起作用,外部的toArray不能编译.
Arrays.stream(intArray):返回Integer []
forEach 的流
:对于每个Integer [],创建一个Integers流,将每个Integer转换为double并返回double [].
for each创建double [],我认为外部toArray将返回此double的数组[]
我怎样才能使它
工作?
我正在寻找配置 google_checks 以4 spaces
在 Maven Checkstyle 插件中使用的方法。我将indentSize
配置参数设置为4,但是不起作用。有配置选项来设置这个吗?我不想拥有自己的版本,google_checks.xml
只是缩进 4 个空格。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<artifactId>checkstyle</artifactId>
<groupId>com.puppycrawl.tools</groupId>
<version>8.36.1</version>
</dependency>
</dependencies>
<configuration>
<configLocation>google_checks.xml</configLocation>
<indentSize>4</indentSize>
<failsOnError>true</failsOnError>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
更新:似乎没有办法有一个与maven-checkstyle-plugin
,Checkstyle with google_checks
和兼容的单一格式Intellij with google_java_format
。有人能够实现这一目标吗?
我有 Zuul + Eureka + Spring Boot Service Endpoint + Hateoas 响应配置。当我通过 Zuul Gateway 访问服务时,响应中的资源链接是到服务端点的直接链接,它们不应该是网关链接吗?我在这里缺少什么?
网关端点:http://localhost:8762/catalog/products/10001 直接服务端点:http://localhost:8100/products/10001
Zuul 的 application.properties
spring.application.name=zuul-server
eureka.client.service-url.default-zone=http://localhost:8761/eureka/
# Map paths to services
zuul.routes.catalog-service=/catalog/**
zuul.addProxyHeaders=true
Run Code Online (Sandbox Code Playgroud)
网关端点的实际响应:http://localhost:8762/catalog/products/10001
{
"title" : "The Title",
"description" : "The Description",
"brand" : "SOME BRAND",
"price" : 100,
"color" : "Black",
"_links" : {
"self" : {
"href" : "http://localhost:8100/products/10001"
}
}
}
Run Code Online (Sandbox Code Playgroud)
预期响应应在 href 中包含网关 URL
{
"title" : "The Title",
"description" : "The Description",
"brand" : "SOME …
Run Code Online (Sandbox Code Playgroud) spring spring-hateoas spring-boot netflix-eureka netflix-zuul
2d ×1
arrays ×1
checkstyle ×1
java ×1
java-8 ×1
lambda ×1
maven ×1
netflix-zuul ×1
spring ×1
spring-boot ×1