1、STS与P3C集成
1)模版导入
阿里规范提供的有2个代码模版文件,导入到sts中
Window>>Preferences>>Java>>Code Style
选中Code Template,导入p3c-codetemplate.xml
阿里开发规范及P3C插件选中formatter,导入p3c-codestyle.xml
阿里开发规范及P3C插件2)插件安装
Help >> Install New Software>>add
阿里开发规范及P3C插件点击OK
阿里开发规范及P3C插件选中插件,继续
点击下一步
阿里开发规范及P3C插件接受协议,点击Finish
阿里开发规范及P3C插件中间可能会提示,选择Install anyway
阿里开发规范及P3C插件安装完成,重启
3)使用方法
Window>>Show View>>Others,选择SmartFoxViews,点击Open
阿里开发规范及P3C插件P3C Results和Rule Detail面板会出现在当前视图上
阿里开发规范及P3C插件以一个Springboot Demo工程为例,在项目上包上或者类上右键点击,阿里编码规约扫描
阿里开发规范及P3C插件在项目上包上或者类上
阿里开发规范及P3C插件扫描后会有相应的提示标识和详细信息,还可迅速定位解决。
2、IDEA与P3C集成
1)模版导入
File>>Settings>>Code Style>>Java>>Import Schema
导入CodeStyle
阿里开发规范及P3C插件选中formatter,导入p3c-codestyle.xml
2)插件安装
File>>Settings>>Plugins>>Browser repositories
阿里开发规范及P3C插件点击Install安装插件,安装完成后重启IDEA
如果在线安装不成功,可以手动下载插件zip包,然后Install plugin from disk,从本地安装插件
下载地址:https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines
阿里开发规范及P3C插件选择zip文件,安装
阿里开发规范及P3C插件3)使用方法
项目或包或类上,点击右键
阿里开发规范及P3C插件编码规约扫描
阿里开发规范及P3C插件扫描结果展示如上图
网友评论