美文网首页程序员
阿里开发规范及P3C插件

阿里开发规范及P3C插件

作者: 木易小刀 | 来源:发表于2018-07-04 23:04 被阅读30次

    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插件

    扫描结果展示如上图

    相关文章

      网友评论

        本文标题:阿里开发规范及P3C插件

        本文链接:https://www.haomeiwen.com/subject/wugyuftx.html