重启后的Ulimit chnage没有效果(Ulimit chnage after reboot as no effect)
我已经更改了
/etc/security/limits.com
并远程重启了计算机。但是,在启动之后,nproc
参数仍然是旧值。[ost@compute-0-1 ~]$ cat /etc/security/limits.conf * - memlock -1 * - stack -1 * - nofile 4096 * - nproc 4096 <===================================== [ost@compute-0-1 ~]$ Broadcast message from root@compute-0-1.local (/dev/pts/0) at 19:27 ... The system is going down for reboot NOW! Connection to compute-0-1 closed by remote host. Connection to compute-0-1 closed. ost@cluster:~$ ssh compute-0-1 Warning: untrusted X11 forwarding setup failed: xauth key data not generated Last login: Tue Sep 27 19:25:25 2016 from cluster.local Rocks Compute Node Rocks 6.1 (Emerald Boa) Profile built 19:00 23-Aug-2016 Kickstarted 19:08 23-Aug-2016 [ost@compute-0-1 ~]$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 516294 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 4096 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 1024 <========================= virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
请注意我将
max user processes
设置为4096,但重启后,该值仍为1024。I have changed
/etc/security/limits.com
and rebooted the machine remotely, However, after the boot, thenproc
parameter has still the old value.[ost@compute-0-1 ~]$ cat /etc/security/limits.conf * - memlock -1 * - stack -1 * - nofile 4096 * - nproc 4096 <===================================== [ost@compute-0-1 ~]$ Broadcast message from root@compute-0-1.local (/dev/pts/0) at 19:27 ... The system is going down for reboot NOW! Connection to compute-0-1 closed by remote host. Connection to compute-0-1 closed. ost@cluster:~$ ssh compute-0-1 Warning: untrusted X11 forwarding setup failed: xauth key data not generated Last login: Tue Sep 27 19:25:25 2016 from cluster.local Rocks Compute Node Rocks 6.1 (Emerald Boa) Profile built 19:00 23-Aug-2016 Kickstarted 19:08 23-Aug-2016 [ost@compute-0-1 ~]$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 516294 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 4096 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 1024 <========================= virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
Please see that I set
max user processes
to 4096 but after the reboot, the value is still 1024.
原文:https://stackoverflow.com/questions/39729510
最满意答案
我找到了解决方案。 我必须使用属性
contentUsing
而不是像这样在注释中using
:@JsonSerialize(contentUsing = JsonDateSerializer.class)
contentUsing属性用于集合。 从课堂文档:
序列化器类,用于序列化注释属性的内容(集合/数组的元素,地图值)。 只能用于属性(方法,字段,构造函数),而不能用于类本身(因为它们通常是通用的)。
I found the solution. I had to use property
contentUsing
instead ofusing
in annotation like this:@JsonSerialize(contentUsing = JsonDateSerializer.class)
contentUsing property is used for collections. From class documentation:
Serializer class to use for serializing contents (elements of a Collection/array, values of Maps) of annotated property. Can only be used on properties (methods, fields, constructors), and not value classes themselves (as they are typically generic).
相关问答
更多-
如果您不想更改POJO类的合约,请考虑定义分别扩展JsonSerializer
和JsonDeserializer 的自定义Jackson序列化器/解串器的可能性。 例如: public class CountryDeserializer extends JsonDeserializer { @Override public CountryCode deserialize(final JsonParser jp, final Deserializa ... -
我终于找到了解决方案! 感谢indybee给我一个线索。 Spring 3.1,Hibernate 4和Jackson-Module-Hibernate教程为Spring 3.1和更早版本提供了一个很好的解决方案。 但是自3.1.2版本以来,Spring有自己的MappingJackson2HttpMessageConverter,与教程中的功能几乎相同,所以我们不需要创建这个自定义的HTTPMessageConverter。 使用javaconfig,我们不需要创建一个HibernateAwareObje ...
-
杰克逊日期反序列化错误(Jackson date deserialization wrong)[2023-06-09]
你有不正确的日期时间模式。 该模式应该是yyyyMM dd hhmmss。 'D'代表每年的Day,'d'代表每月的Day。 You have the incorrect datetime pattern. The pattern should be yyyyMMdd hhmmss. 'D' for Day in year and 'd' for Day in month. -
如何让泽西/杰克逊序列化空列表;(How to make Jersey/Jackson serialize empty list; single element list as an array)[2022-04-13]
我很确定你实际上并没有使用Jackson(JSON序列化的“POJO”变体),因为Jackson不会将单元素数组或列表转换为其他任何东西。 所以你可能正在使用一种传统的输出方法(如jettison); 这意味着如果您将系统配置为使用POJO映射,它应该可以正常工作。 I am pretty sure that you are not actually using Jackson ("POJO" variant of JSON serialization), since Jackson would not c ... -
杰克逊序列化(Jackson Serialization)[2022-09-20]
Json将map的键作为String处理,并且它的默认实现只是调用它的toString方法。 以下文章有清楚的解释,这可能会帮助你。 使用JSON时,我们可以使对象成为地图中的关键字吗? Json treats map's key as String and it default implementation simply calls its toString method. The following post has clear explanantion, this might help you. Ca ... -
我认为你应该使UserInfo静态。 杰克逊不能构建UserInfo类。 我尝试过这种改变,它适用于我: public class User { private List
userInfoList; public static class UserInfo { private String id; public UserInfo() { super(); } public St ... -
我找到了解决方案。 我必须使用属性contentUsing而不是像这样在注释中using : @JsonSerialize(contentUsing = JsonDateSerializer.class) contentUsing属性用于集合。 从课堂文档: 序列化器类,用于序列化注释属性的内容(集合/数组的元素,地图值)。 只能用于属性(方法,字段,构造函数),而不能用于类本身(因为它们通常是通用的)。 I found the solution. I had to use property conten ...
-
private static final Pattern pat = Pattern.compile("/Date\\((\d+)[\\+\\-](\\d+)\\)/"); ... String data = "/Date(1379542610387+1000)/"; Matcher m = pat.matcher(data); if (m.matches()) { long time = Long.valueOf(m.group(1)); int offset = Integer.v ...
-
我认为你最好的选择是在序列化时传递一种新的日期格式。 例如: final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm")); 基于github上的JavaDocs,它可以深入了解如何确定日期格式,而无需指定自己的格式,我认为您只能使用数字时间戳或Jackson定义的内置ISO格式。 文件供参考: /** * F ...
-
使用@JsonInclude注释。 @JsonInclude(Include.NON_NULL) class Foo { String bar; } 编辑 您也可以创建自己的序列化程序。 例如 : public static void main(String[] args) throws JsonProcessingException { List
strings = new ArrayList<>(); strings.add("string 1" ...