如何使用-Xlint编译:在Maven项目中取消选中?

Ale*_*ing 53 java netbeans maven

在NetBeans 7.2中,我很难找到如何使用-Xlint进行编译:在Maven项目中未选中.在Ant项目下,您可以通过转到项目属性 - >编译来更改编译器标志,但Maven项目似乎没有任何此类选项.

有没有办法配置IDE使用Maven编译这些标志?

Nis*_*ant 70

我想你可以在你的pom.xml中设置编译器参数.请参阅http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html

 <compilerArgument>-Xlint:unchecked</compilerArgument>
Run Code Online (Sandbox Code Playgroud)

  • 链接的页面建议&lt;CompilerArgument&gt;条目应放在&lt;CompilerArguments&gt;组中。这似乎合乎逻辑。按照下面的链接,它实际上位于&lt;configuration&gt;组中。/sf/ask/575104701/ (2认同)

Raj*_*ajV 42

我想详细说明@Nishant的答案.该compilerArgument标签需要里面去plugin/configuration标记.这是一个完整的例子:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
      <testSource>1.8</testSource>
      <testTarget>1.8</testTarget>
      <compilerArgument>-Xlint:unchecked</compilerArgument>
    </configuration>
  </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

  • 提供需要进入的上下文参数是有用答案的重要组成部分。谢谢! (2认同)