【发布时间】:2021-08-21 15:27:27
【问题描述】:
我正在 VScode 中开发一个 Maven Java 项目,我想使用 https://code.visualstudio.com/docs/java/java-linting 来格式化和自动更正源代码中的 checkstyle 错误。
我安装了扩展,从 command-pallet 配置了 google_checks.xml,设置了 checkstyle 版本,然后尝试从 command-palet 中使用“check code with checkstyle”命令触发它。
什么都没发生……
我的 settings.json 如下所示:
{
"java.configuration.updateBuildConfiguration": "automatic",
"java.checkstyle.configuration": "/google_checks.xml",
"java.checkstyle.version": "8.43"
}
[编辑]
我的 pom.xml 是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>sun_checks.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
我忘了说这是一个 Maven 项目。我激活了 Maven 站点命令,我看到报告 273 错误,然后将扩展名也配置为 sun_check.xml,但当我尝试使用它时再次没有结果。
为了触发这个扩展缺少什么?
【问题讨论】:
-
方便的话可以贴出你的代码吗?
标签: java visual-studio-code checkstyle