如何防止Eclipse格式化程序在注释注释后添加空格?

时间:2015-10-05 10:18:41

标签: java eclipse code-formatting eclipse-formatter

格式化此代码时:

@JoinTable(name = "UTI_COLLECTER_CTN",
  joinColumns = @JoinColumn(name = "COD_UTI", referencedColumnName = "COD_UTI"),
  inverseJoinColumns = @JoinColumn(name = "COD_CTN", referencedColumnName = "COD_CTN"))

eclipse在注释的每个右括号注释后添加一个空格,如下所示:

@JoinTable(name = "UTI_COLLECTER_CTN",
  joinColumns = @JoinColumn(name = "COD_UTI", referencedColumnName = "COD_UTI") ,
  inverseJoinColumns = @JoinColumn(name = "COD_CTN", referencedColumnName = "COD_CTN") )

如何预防? (删除格式化程序配置中的所有空格不会改变任何内容......)

2 个答案:

答案 0 :(得分:1)

我终于找到了一个解决方法,我在内部注释之前和之后添加了大括号:

@JoinTable(name = "UTI_COLLECTER_CTN",
  joinColumns = {@JoinColumn(name = "COD_UTI", referencedColumnName = "COD_UTI")},
  inverseJoinColumns = {@JoinColumn(name = "COD_CTN", referencedColumnName = "COD_CTN")})

答案 1 :(得分:-1)

1)转到窗口 - >偏好 - > Java - >代码风格 - >格式化器

2)点击“编辑”

3)打开选项卡空格

4)展开“声明”

5)单击“注释”

6)您可以在下面找到白色间距的选项。

7)去除“关闭之前”的厚度

我为此附上了照片。 enter image description here