小编Joh*_*ria的帖子

在Repository注册表初始化期间发生Eclipse错误

我突然遇到初始化Eclipse Kepler的错误:

An internal error occurred during: "Repository registry initialization".
For input string: "(pilgrim's conflicted copy 2013-10-18).gen"
Run Code Online (Sandbox Code Playgroud)

eclipse maven

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

返回JSON中的Jersey异常

以JSON格式返回Jersey异常的最佳方法是什么?这是我的示例代码.

    public static class CompoThngExceptionMapper implements ExceptionMapper<Exception> {
    @Override
    public Response toResponse(Exception exception) {
        if (exception instanceof WebApplicationException) {
            WebApplicationException e = (WebApplicationException) exception;
            Response r = e.getResponse();
            return Response.status(r.getStatus()).entity(**HERE JSON**).build();
    } else {
            return null;

        }
    }
Run Code Online (Sandbox Code Playgroud)

提前致谢!!!

json jersey

6
推荐指数
2
解决办法
1万
查看次数

.git / info / exclude中的文件不起作用

我已经放入了两个文件,.git/info/exclude但仍然可以看到它们git st

它们是一个配置文件,我不想提交更多。我把它们放在那里,因为有--assume-unchanged--skip-worktree我无法检出到另一个分支。

git github

6
推荐指数
2
解决办法
3987
查看次数

ElasticSearch可以返回单个文档数组的元素吗?

带有如下文档:

{
    "obj1" : [
        {
            "name" : "blue",
            "count" : 4
        },
        {
            "name" : "green",
            "count" : 6
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

是否可以查询a obj1.name = "blue"以获得数组而不是文档的匹配元素?:

{
    "name" : "blue",
    "count" : 4
}
Run Code Online (Sandbox Code Playgroud)

提前致谢!

elasticsearch

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

使用PowerMock在可靠的测试中模拟静态类

是否有任何方法可以放心使用PowerMock,因为当我试图用放心的方式测试RESTful API时.

我想要PowerMock静态调用.

操作规范:

@POST
@Produces("application/json")
@Consumes(MediaType.APPLICATION_JSON)
public Response createEntity(@Context HttpHeaders hh, String body) {
    . . . 

    String sec = MDI.check(Some_string, ..., ...);
    if (sec == null) throw ...

    return Response....
}
Run Code Online (Sandbox Code Playgroud)

而且测试:

@RunWith(PowerMockRunner.class)
@PrepareForTest(MDI.class)
public class createSOTest {

    @Test
    public void testStatic() {
        mockStatic(MDI.class);

        expect(MDI.check(Some_string, ..., ...).andReturn(Some_String);
        replay(MDI.class)

        given().
            contentType(ContentType.JSON).
            header("SomeHeader", "something").
            body(root).
        when().
            post("/").
        then().
            statusCode(...);
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是我在测试尝试运行rest-assuredcode(given()....)时获得异常:

org.apache.http.conn.ssl.SSLInitializationException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLS10Context not a SSLContext
    at org.apache.http.conn.ssl.SSLContexts.createDefault(SSLContexts.java:58)
    at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:162)
    at …
Run Code Online (Sandbox Code Playgroud)

java junit4 powermock rest-assured

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

双显示器不同分辨率

配置具有不同屏幕分辨率的双显示器环境的正确方法是什么?

我在两个屏幕上的字体大小都非常不同,我找不到如何为每个显示器或其他任何配置不同的 dpi。

提前致谢!

kde kde4 kubuntu

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

仅当存在(如果用户填写)无效时才验证数字

我遵循一些提示,仅在存在时验证字段的数字性,使用:

validates_numericality_of :year, only_integer: true, allow_nil: true
Run Code Online (Sandbox Code Playgroud)

或者

validates_numericality_of :year, only_integer: true, allow_blank: true
Run Code Online (Sandbox Code Playgroud)

但是我可以用类似的年份来创建它,'asdfasdf'而 rails 可以存储空白的年份。

有什么问题?

ruby-on-rails ruby-on-rails-4

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

使用HttpAsyncClients设置重试次数

通过典型HttpAsyncClients示例:

public class AsyncClientHttpExchange {

    public static void main(final String[] args) throws Exception {
        CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        try {
            httpclient.start();
            HttpGet request = new HttpGet("http://httpbin.org/get");
            Future<HttpResponse> future = httpclient.execute(request, null);
            HttpResponse response = future.get();
            System.out.println("Response: " + response.getStatusLine());
            System.out.println("Shutting down");
        } finally {
            httpclient.close();
        }
        System.out.println("Done");
    }
}
Run Code Online (Sandbox Code Playgroud)

如果没有响应,设置重试次数的方法是什么?我可以看到5.

随着httpClientBuilder存在setRetryHandler:

httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));
Run Code Online (Sandbox Code Playgroud)

有什么办法HttpAsyncClients

apache httpclient apache-httpclient-4.x apache-httpasyncclient

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

mpi处理器数量错误

对不起,我确定犯了一个愚蠢的错误,但没有成功.

我正在编译一个简单的mpi hello世界:

#include <stdio.h>
#include <mpi.h>

int main (argc, argv)
     int argc;
     char *argv[];
{
  int rank, size;

  MPI_Init (&argc, &argv);      /* starts MPI */
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);        /* get current process id */
  MPI_Comm_size (MPI_COMM_WORLD, &size);        /* get number of processes */
  printf( "Hello world from process %d of %d\n", rank, size );
  MPI_Finalize();
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

和:

> mpicc -o hello_world_c hello_world.c
> mpirun -np 4 hello_world_c
Run Code Online (Sandbox Code Playgroud)

但回报:

Hello world from process 0 of 1
Hello world …
Run Code Online (Sandbox Code Playgroud)

mpi processors

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

vim航空公司的奇怪角色

在此输入图像描述

我不知道如何删除master分支后的字符(倒置E)

vim vim-airline

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