我有一个项目,我使用gradle来构建.在我安装Gradle Eclipse插件之前,我能够在Eclipse中看到gradle build文件夹.但在安装插件(Buildship)并创建和构建新的Gradle项目后,我无法再在Project Explorer或Package Explorer或Navigator中看到build文件夹.我能够从Windows资源管理器中看到build文件夹和jar文件.我试图从自定义视图...更改设置,但它没有解决问题.有人可以让我知道如何让build文件夹出现吗?谢谢.
这是build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
mainClassName = 'com.ii.mainClass'
repositories {
mavenCentral()
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.6.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.1'
compile 'org.springframework:spring-beans:4.2.0.RELEASE'
compile 'org.springframework:spring-context:4.2.0.RELEASE'
compile 'org.springframework:spring-core:4.2.0.RELEASE'
compile 'org.springframework:spring-expression:4.2.0.RELEASE'
compile 'org.springframework.xd:spring-xd-tuple:1.0.4.RELEASE'
}
Run Code Online (Sandbox Code Playgroud) 我有一个 Person 类:
@Data
public class Person {
private Integer id;
private String status;
}
Run Code Online (Sandbox Code Playgroud)
我有一个名为 personList 的人员列表:
[{
"id": null,
"status": "inactive"
},
{
"id": 2,
"status": "inactive"
},
{
"id": null,
"status": "active"
}]
Run Code Online (Sandbox Code Playgroud)
现在我需要找到所有状态为“非活动”的人,无论该人是否有 Id。如果某人没有 Id,但状态为“活跃”,则也包括该人。我正在使用 Java 流进行过滤:
List<Person> inactivePersonList =
personList.stream()
.filter(person -> person.getStatus().equals("inactive"))
.filter(person -> person.getId() == null && person.getStatus().equals("active"))
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
直播后的结果是没人接听。第一个人没有被选中,因为它没有通过第二个过滤器,最后一个人没有被选中,因为它没有通过第一个过滤器。
我想我可以通过使用 将两个过滤器合二为一来修复它OR,但我试图使每个过滤器变得简单,所以在我进行更改之前,我想问一下是否有更好的方法来做到这一点。谢谢。
我是 Spring WebClient 的新手。我有以下方法使用 WebClient 调用端点,并且我需要从此方法返回 ResponseEntity。我知道我可以 call block(),但是我是否可以以非阻塞的方式做到这一点?即使我可以 return Mono,调用方法仍然需要解开它并获取 ResponseEntity ,调用方法如何执行,调用block?
public ResponseEntity getData() {
Mono<ResponseEntity<String>> entityMono = webClient.post()
.uri(url)
.body(BodyInserters.fromValue(aString))
.retrieve()
.toEntity(String.class);
// what do I need to do here so that I can return ResponseEntity non-blocking
}
Run Code Online (Sandbox Code Playgroud) 我有Scala类,它将生成一个Option[StructType]将在Java函数中使用的值.在那个java函数中,我需要检查它是否Option[StructType]是Scala None.我怎么做?
class Person(columns : String) {
val recordStruct : Option[StructType] = {
if ( columns != null && !columns.isEmpty()) {
Some(new StructType(fields.map(field =>
StructField(field, StringType, true)).toArray))
} else {
None
}
}
}
Run Code Online (Sandbox Code Playgroud)
StructType structure = person.recordStruct().get();
// how to check if structure is None (in scala) ????
if (structure is None) {
// ...
}
Run Code Online (Sandbox Code Playgroud) 有没有一种简单的方法可以将逗号分隔的字符串转换为 Scala 中的 LinkedHashSet?目标是删除字符串中的重复项,但它需要一个 FOR 循环。所以我想我可以将 String 拆分成像 LinkedHashSet 这样的集合,它可以保留原始顺序并删除重复项。我做了一些研究,但没有找到方法。所以想在这里确认一下是否可行。
例如,对于字符串:
aaa, bbb, ccc, aaa, ddd
Run Code Online (Sandbox Code Playgroud)
我想让它成为:
aaa, bbb, ccc, ddd
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个类似"info_A!__ B ???????? C_*"的字符串.我想删除它中的特殊字符,但保留下划线和字母.我尝试使用[:word:](ASCII字母和_)字符集,但它说"无效字符集".任何想法如何处理这个?谢谢.
text="info_!_????????_*"
if [ -z `echo $text | tr -dc "[:word:]"` ]
......
Run Code Online (Sandbox Code Playgroud) 我有一个StructType类型的架构:
val schema = getSchema(); // getSchema returns StructType
Run Code Online (Sandbox Code Playgroud)
我创建了另一个类型为StructField的字段:
StructField("NAME", StringType, false)
Run Code Online (Sandbox Code Playgroud)
我知道可以调用schema.add()方法将NAME字段添加到现有模式的末尾,但是如何将NAME添加到模式的开头以使其成为第一列?谢谢。
我正在测试我的 DAO 类,它使用扩展 RestTemplate 的自定义 RestTemplate 来执行 postForObject,但即使在向 pom.xml 添加字节伙伴依赖项后,我仍然收到以下错误。这个错误似乎发生在对 Mock() 的调用中。有人可以让我知道我做错了什么吗?
NoClassDefFoundError: net/bytebuddy/TypeCache
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.3.16</version>
<scope>test</scope> <!--also tried giving "runtime" here -->
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的道课:
@Component
public class DaoClass {
@Autowired
private MyCustomRestTemplate restTemplate;
public SomeObjectType getAddressFromSomewhere(
String url, String request) {
......
return restTemplate.postForObject(url, request, SomeObjectType.class);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经设置了一个 TestConfiguration 类,以便测试 restTemplate bean 将用于测试:
@Configuration
public class TestConfiguration {
@Bean
public MyCustomRestTemplate restTemplate() {
return new MyCustomRestTemplate();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我嘲笑 restTemplate postForObject 的 Spock 代码:
@ContextConfiguration(classes = …Run Code Online (Sandbox Code Playgroud)