侧边栏壁纸
  • 累计撰写 49 篇文章
  • 累计创建 23 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

IDEA 配置 google-java-format 插件

阿砖
2024-10-21 / 0 评论 / 0 点赞 / 352 阅读 / 2349 字
  1. 使用 Ctrl +Alt + s 开启 settings 界面并且选择 Plugins 页面

  1. 输入框中输入 google-java-format 点击 Install 按钮进行安装

  1. 安装完成后会提示重启 IDEA ,点击确认重启下 IDEA

  2. 再次打开 IDEA 之后 选择 Help -> Edit Custom VM Options... 添加下面的内容到该文件

--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
  1. 手动重启 IDEA

  2. 默认情况下插件被禁用。要启用请打开项目设置,然后单击“google-java-format 设置”并选中“启用 google-java-format”复选框。

至此 IDEA 的 google-java-format 插件已经添加完毕,指接使用 Ctrl +Alt + L 即可按照 插件的规则格式化。不过 google-java-format 的格式化并不能自定义不过无所谓也挺好看。

0

评论区