java - 我如何更改我的 Eclipse 源格式化程序设置来处理以下示例?

标签 java eclipse

这段代码是我在eclipse中写的

protected void createTables(SQLiteDatabase db) {
        db.execSQL(
                                          "create table " + CUSTOMERS_TABLE +" (" +                     
                        CustomerId + " text primary key," +
                        FirstName + " text," +
                        MiddleName + " text," +
                        LastName + " text," +
                        Portrait + " BLOB," +
                        Gender + " integer," +
                        Age + " integer," +
                        Passed + " integer"+
                ");"

但是当我使用 source->format eclipse 格式化我的代码时,使它们像这样

protected void createTables(SQLiteDatabase db) {
        db.execSQL("create table " + CUSTOMERS_TABLE + " (" + CustomerId
                + " text primary key," + FirstName + " text," + MiddleName
                + " text," + LastName + " text," + Portrait + " BLOB," + Gender
                + " integer," + Age + " integer,"
                + Passed
                + " integer" +");"

我希望 eclipse 格式化程序保留我的代码。我应该设置哪些设置?

最佳答案

//@formatter:off//@formatter:on 之间包含您不希望 eclipse 重新格式化的行:

protected void createTables(SQLiteDatabase db) {
    // @formatter:off
    db.execSQL(
                                      "create table " + CUSTOMERS_TABLE +" (" +                     
                    CustomerId + " text primary key," +
                    FirstName + " text," +
                    MiddleName + " text," +
                    LastName + " text," +
                    Portrait + " BLOB," +
                    Gender + " integer," +
                    Age + " integer," +
                    Passed + " integer"+
            ");"
    // @formatter:on

关于java - 我如何更改我的 Eclipse 源格式化程序设置来处理以下示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14058921/

相关文章:

android - 在 Eclipse 中使用来自 GitHub 的 Maven Android 库

java - 如果设置了给定的 java 属性,如何使用 Eclipse Core Expression 计算结果为 true?

eclipse - 如何在WindowBuilderPro中使用TableViewer?

java - 如何在 Debug模式下查看 Eclipse 中的调用树?

java - 如何以编程方式正确添加 View ?

java - OpenCV android函数使用

java - @SpringBootApplication 在同一个包中?

java - 如何在另一个 Java 类中使用枚举?

java - 如何通过 JDBC 从 MS Access "Attachment"字段检索文件?

java - 如何将图像字节传递给 Velocity 模板