小编Emd*_*won的帖子

如何在Intellij中更改所有项目的项目语言级别

我正在使用Intellij.这很好,但是当我创建一个新项目或导入项目时,默认项目语言级别设置为6(接口中的@override).但是我想把它设置为8(Lambdas,类型注释等).我怎样才能做到这一点?我尝试更改"其他设置" - >"默认项目结构"中的设置,并将项目语言级别设置为8,但没有运气.请有人帮助我.我添加了一个屏幕截图.在此输入图像描述

  • 我正在使用Intellij 14.0.2

intellij-idea intellij-14

28
推荐指数
4
解决办法
3万
查看次数

以编程方式从Java导出和导入apached数据到LDIF

我在Apache Directory Studio中创建了一个服务器.我还创建了一个分区,并将一些条目插入到Java服务器中.现在我想以编程方式备份​​和恢复此数据和LDIF文件.我是LDAP新手.所以请告诉我一个详细的方法,使用java从我的服务器以编程方式导入和导入条目到LDIF.

当前解决方案

现在我使用这种方法进行备份:

  EntryCursor cursor = connection.search(new Dn("o=partition"), "(ObjectClass=*)", SearchScope.SUBTREE, "*", "+"); 
  Charset charset = Charset.forName("UTF-8");
  Path filePath = Paths.get("src/main/resources", "backup.ldif");
  BufferedWriter writer = Files.newBufferedWriter(filePath, charset);
  String st = ""; 

  while (cursor.next()) { 
    Entry entry = cursor.get();
    String ss = LdifUtils.convertToLdif(entry);
    st += ss + "\n";
  }
  writer.write(st);
  writer.close();
Run Code Online (Sandbox Code Playgroud)

为了恢复,我使用这个:

  InputStream is = new FileInputStream(filepath);
  LdifReader entries = new LdifReader(is);

  for (LdifEntry ldifEntry : entries) {
    Entry entry = ldifEntry.getEntry();

    AddRequest addRequest = new AddRequestImpl();
    addRequest.setEntry(entry);
    addRequest.addControl(new ManageDsaITImpl()); …
Run Code Online (Sandbox Code Playgroud)

java ldap ldif apacheds

7
推荐指数
1
解决办法
3210
查看次数

Spring MVC映射请求主体到基本类型

我想通过spring mvc处理简单的POST请求。请求正文仅包含一个int值。谁能帮我写动作方法。我的代码如下:

@PostMapping(value = "/update")
@ResponseBody
public ResponseEntity updateLogLevel(@RequestBody int level) {
    try {
        //process request
    } catch (Exception ex) {
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }
    return ResponseEntity.ok(Constant.STATUS_SUCCESS);
}
Run Code Online (Sandbox Code Playgroud)

但是这段代码抛出异常:

org.springframework.http.converter.HttpMessageNotReadableException",
"message":"JSON parse error: Can not deserialize instance of int out of START_OBJECT token; 
nested exception is 
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of int out of START_OBJECT token
Run Code Online (Sandbox Code Playgroud)

我的请求正文:

{
    "level" : 100
}
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-boot

1
推荐指数
1
解决办法
1575
查看次数