我需要按类型将数据列表分成不同的列表,为此我使用构造
Map<String,List<Dish>> dishMap = menu.stream()
.collect(Collectors.groupingBy(Dish::getType));
Run Code Online (Sandbox Code Playgroud)
但是如何从方法"Collectors.groupingBy"获取LinkedHashMap而不是HashMap.我在javadoc中找到了一些数据但是我不能得到我必须用这个方法做的事情:
Map<String,List<Dish>> dishMap = menu.stream().collect(Collectors.groupingBy(
Dish::getType,
LinkedHashMap::new, ????));
Run Code Online (Sandbox Code Playgroud)
我应该在方法"groupingBy"的第三个参数中放置什么才能得到我需要的东西?
我曾经使用像这样的Spring 属性来支持Java Date或Joda Localdate模式绑定DateTimeFormat pattern
@DateTimeFormat(pattern = "dd.MM.yyyy")
private LocalDate creationDate;
Run Code Online (Sandbox Code Playgroud)
但我需要支持两种日期模式,例如:
如果用户输入31/12/1999或31/12/99,则两者都可以绑定到相同的值31/12/1999.是否可以为此定义两种模式@DateTimeFormat?
编辑:
我试图将模式更改为
@DateTimeFormat(pattern = "dd.MM.yy")
private LocalDate creationDate;
Run Code Online (Sandbox Code Playgroud)
我发现它可以处理这两种情况(例如当用户输入31/12/1999或者31/12/99两者都受到约束时)31/12/1999.任何意见?
我曾经通过使用@Path以下Java EE 教程对其进行注释来将服务和 DAO bean 集成到 Jersey REST 资源中
一般来说,要让 JAX-RS 与企业 bean 一起工作,您需要使用 @Path 注释 bean 的类以将其转换为根资源类。您可以将 @Path 注释与无状态会话 bean 和单例 POJO bean 一起使用。
所以我的代码曾经是这样的:
@Path("/")
public class ServiceResource {
@Inject
private AccountService accountService;
@GET
@Path("/account/get")
public Account getAccount(@QueryParam("id") String id) {
return accountService.get(id);
}
}
@javax.inject.Singleton
@Path("")
public class AccountService {
public Account get(String id){...}
}
Run Code Online (Sandbox Code Playgroud)
现在,我开始将 Quartz Job 集成到我的应用程序中,我想找到一种方法将我AccountService的工作注入到这样的工作中
public class AccountJob implements Job {
@Inject
private AccountService accountService;
@Override
public …Run Code Online (Sandbox Code Playgroud) 如何在Clojure中重写这个Ruby代码?
seq = [1, 2, 3, 4, 5].each_cons(2)
#=> lazy Enumerable of pairs
seq.to_a
=> [[1, 2], [2, 3], [3, 4], [4, 5]]
Run Code Online (Sandbox Code Playgroud)
Clojure的:
(??? 2 [1 2 3 4 5])
;=> lazy seq of [1 2] [2 3] [3 4] [4 5]
Run Code Online (Sandbox Code Playgroud) 我应该绑定到一个复杂对象的形式,装载这种形式我必须初始化所有的孩子,只有有很多的方法,对象之前包裹了很多孩子,每次new报表和调用一个setter方法,我要对许多表单和其他复杂对象重复此方案
有没有比initializeEmployee方法更好的策略?
例如:
@Entity
public class Employee {
Integer Id;
Contract contract;
Name name;
List<Certificate> list;
// getter and setters
}
@Entity
public class Contract {
String telephoneNum;
String email;
Address address;
// getter and setters
}
@Entity
public class Address {
String streetName;
String streetNum;
String city;
}
public class Name {
String fName;
String mName;
String lName;
// getter and setters
}
// And another class for certificates
public initializeEmployee() {
Employee …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Glassfish 4.0(build 89)中创建一个LDAP领域,但每次我尝试到目前为止,都会发生以下错误:
"无效的属性语法,"="in value:base-dn = [...]"
我尝试使用不同的浏览器并在Netbeans中重新安装Glassfish.奇怪的是,我的一个朋友可以复制我的base-dn并且它有效.
提前致谢!
java ×4
spring ×2
clojure ×1
collectors ×1
date ×1
date-format ×1
glassfish ×1
grouping ×1
hibernate ×1
jakarta-ee ×1
java-8 ×1
jax-rs ×1
jodatime ×1
ldap ×1
netbeans ×1
rest ×1
ruby ×1
spring-mvc ×1