小编dib*_*ger的帖子

Spring Boot 错误控制器检索原始请求

默认情况下,Spring Boot 映射/errorBasicErrorController. 我想记录异常以及导致异常的请求。如何获取原始请求BasicErrorController或新的CustomErrorController. 似乎Spring Boot会/error在抛出异常并且原始请求信息消失或无法将错误与原始请求映射时发出新请求。 在此处输入图片说明

java spring spring-boot

6
推荐指数
3
解决办法
2635
查看次数

如何在 Vert.x 中运行多个顶点?

我是 Vert.x 的新手,我想通过 jar 运行多个 Verticle。我有两个文件,一个是 MyFirstVertice.java,它路由路径“/q1/ ”并返回一些东西。第二个是 MySecondVertice.java,它路由路径“/q2/ ”。第二个顶点部署在第一个顶点中。

MyFirstVertice.java

public class MyFirstVerticle extends AbstractVerticle {
@Override
public void start(Future<Void> fut) throws Exception {

    HttpServer server = vertx.createHttpServer();
    Router router = Router.router(vertx);
    router.route("/q1/*").handler(routingContext -> {
        HttpServerRequest request = routingContext.request();
        String Y = request.getParam("key");
        String cipherText = request.getParam("message");

        HttpServerResponse response = routingContext.response();

        response.setChunked(true);
        response.putHeader("content-type", "text/plain");
        response.write(Y + "\n");
        response.write(cipherText + "\n");
        response.end();

        vertx.deployVerticle(new MySecondVerticle(), stringAsyncResult -> {
            System.out.println("Second verticle is deployed successfully.");
        });
    });

    server.requestHandler(router::accept).listen(8080, httpServerAsyncResult -> {
        if (httpServerAsyncResult.succeeded()) …
Run Code Online (Sandbox Code Playgroud)

java maven web vert.x

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

尽管交互式 shell 功能正常,但 Bash 功能不适用于远程 ssh 命令执行

我在.bash_aliases文件中定义了一个函数并将其包含在我的.bashrc文件中。

我的.bash_aliases文件:

function dmidecode() {
        if [[ $1 == -t && $2 == 1 ]]; then
                cat ~/some_file
        else
                command dmidecode "$@"
        fi
}
Run Code Online (Sandbox Code Playgroud)

作用是:当有人执行命令:时dmidecode -t 1,bash从中读取内容~/some_file并返回。

我的.bashrc文件:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or …
Run Code Online (Sandbox Code Playgroud)

unix linux bash shell sh

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

对具有两个属性的对象列表进行排序的时间复杂度是多少?

假设我有一堂课:`

public class Interval {
    int start;
    int end;
    Interval() { start = 0; end = 0; }
    Interval(int s, int e) { start = s; end = e; }
}
Run Code Online (Sandbox Code Playgroud)

`

我想使用 Collections.sort() 对间隔列表进行排序,如下所示:

Collections.sort(intervals, new Comparator<Interval>(){
    @Override
    public int compare(Interval o1, Interval o2) {
        if (o1.start == o2.start) {
            return o1.end - o2.end;
        }
        else {
            return o1.start - o2.start;
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我知道使用内置排序函数对数组进行排序需要 O(nlogn) 时间,问题是如果我对具有两个属性的对象列表进行排序,对该列表进行排序的时间复杂度是多少?谢谢!!

java sorting algorithm

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

标签 统计

java ×3

algorithm ×1

bash ×1

linux ×1

maven ×1

sh ×1

shell ×1

sorting ×1

spring ×1

spring-boot ×1

unix ×1

vert.x ×1

web ×1