3

当我跑mvn clean compile

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <compilerId>javac-with-errorprone</compilerId>
      <forceJavacCompilerUse>true</forceJavacCompilerUse>
      <showDeprecation>true</showDeprecation>
      <showWarnings>true</showWarnings>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-compiler-javac-errorprone</artifactId>
        <version>2.6</version>
      </dependency>
      <dependency>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_core</artifactId>
        <version>2.0.6</version>
      </dependency>
    </dependencies>
  </plugin>

我一直在尝试将MissingOverride其作为错误启用,或者实际上只是为了发出任何东西,对于初学者来说,我需要更改什么才能看到“警告”的输出,那么我应该怎么做才能MissingOverride成为错误?

4

1 回答 1

3

它似乎是一个错误plexus-compiler-javac-errorprone,它不输出警告,但要转换MissingOverride为错误,您可以将-Xep:MissingOverride:ERROR标志传递给编译器,如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
        <compilerId>javac-with-errorprone</compilerId>
        <forceJavacCompilerUse>true</forceJavacCompilerUse>
        <source>1.8</source>
        <target>1.8</target>
        <compilerArgs>
            <arg>-Xep:MissingOverride:ERROR</arg>
        </compilerArgs>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-javac-errorprone</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_core</artifactId>
            <version>2.0.7</version>
        </dependency>
    </dependencies>
</plugin>
于 2015-12-27T06:26:46.783 回答