Spring Tool Suite 配置关联代码检查模板

来源:互联网 发布:java httpclient请求 编辑:程序博客网 时间:2024/05/16 16:12

在一些代码编程规范较为严格的公司,会有公共的代码规范、格式化等的配置模板,需要自己配置到开发工具中,编码后运行检查,如何在Spring Tool Suite(Eclipse)中配置关联这些模板?在此记录一下。

 

1.代码模板文件

window-->preferences  搜索 code templates,在右侧的窗口点击import,将模板文件导入,导入后点击查看是否生效

 


 

 

2.代码格式化模板

window-->preferences  搜索 formatter,在右侧的窗口点击import,将模板文件导入,导入后active profile会自动显示你导入的格式化模板名称

 



 3. 代码规范checkstyle模板

window-->preferences  搜索 checkstyle,右侧窗口点击new按钮,type选择external,然后选择具体模板文件,导入文件后,选中文件,点击 set as default。



 

FAQ:配置好后,运行checkstyle,报错,搜索了网上,说checkstyle新版本中有一些属性去掉了,解决办法,将报错的内容在你导入的check模板文件中去掉

 

安利一下,经常碰到eclipse报错,详细信息让你看日志,在workspace中.metadata文件夹下的.log文件中可以查看到

报错信息

!MESSAGE Checkstyle-Plugin: cannot initialize module TreeWalker - Unable to instantiate 'RedundantThrows' class, it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.RedundantThrows, 

解决

模板文件中将报错的部分去掉

<!--     <module name="RedundantThrows"/> -->

 

 

  • 大小: 19.5 KB
  • 大小: 20.3 KB
  • 大小: 24.3 KB
  • 大小: 32.6 KB
  • 查看图片附件
原创粉丝点击