有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何根据我的示例配置Intellij idea代码格式

在我的测试中,我有很多错误的代码

public void createEntity(String jsonString) {   
    response = getBaseRequestWithCurrentCookie()
            .given().
                    body(jsonString).
                    contentType(ContentType.JSON)
            .when().
                    post()
            .then().
                    log().ifError().
                    extract().response();
}

但是,如何配置intellij Idea代码样式(针对Java)使其不对齐

public void createEntity(String jsonString) {
    response = getBaseRequestWithCurrentCookie()
            .given().
            body(jsonString).
            contentType(ContentType.JSON)
            .when().
            post()
            .then().
            log().ifError().
            extract().response();
}


共 (1) 个答案

  1. # 1 楼答案

    1. 将生成器方法名称添加到设置(macOS上的首选项)|编辑器|代码样式| Java |包装和大括号|链接方法调用|生成器方法
    2. 启用设置(macOS上的首选项)|编辑器|代码样式| Java |包装和大括号|链接方法调用|保持生成器方法缩进选项:

    enter image description here