在NetBeans 7.2中,我很难找到如何使用-Xlint进行编译:在Maven项目中未选中。在Ant项目下,您可以通过转到Project Properties - >来更改编译器标志。编译,但Maven项目似乎没有任何这样的选择。
有没有办法配置IDE使用Maven编译这些标志?
答案 0 :(得分:65)
我猜你可以在你的pom.xml中设置编译器参数。请参阅此http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html
<compilerArgument>-Xlint:unchecked</compilerArgument>
答案 1 :(得分:38)
我想详细说明@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>
答案 2 :(得分:0)
这对我有用...
messagesTable.register(nib, forCellReuseIdentifier: "wallCell")
messagesTable.delegate = self
messagesTable.dataSource = self
答案 3 :(得分:-1)
pom文件信息是现货。我还面临着在Jenkins中构建别人的Maven项目并且无法访问pom文件存储库的额外挑战。
我创建了一个预构建步骤,以便在从git下载之后将编译器参数插入到pom文件中,例如
sed -i 's|/target> *$|/target>\n<compilerArgument>\n-Xlint:deprecation\n</compilerArgument>|' $WORKSPACE/pom.xml