maven为什么Java代码编译有区别:mvn验证与mvn编译
简短版本:
mvn compile
和mvn verify
是否以相同的方式编译代码
问题:
我有一个多模块项目。并使用Maven v3。六,
POM看起来像这样:
<modules>
<module>common</module>
<module>server</module>
<module>plugins</module>
</modules>
服务器模块中的一个类被修改,其中添加了一个新方法。 插件模块中的一个类正在调用该方法
使用以下maven命令成功构建:
mvn clean
mvn compile
mvn -DskipTests verify
但是plugin
模块的编译在我们运行时失败:
mvn clean
mvn -DskipTests verify
在server
模块类中出现一个错误,抱怨没有找到新方法:
error: cannot find symbol
那么,为什么会有这种行为差异呢。根据this documentationverify
应该首先调用compile
。因此,实际上与第一个版本的命令是一样的
注意事项:
- 也会失败
mvn -DskipTests compile verify
- 已成功生成:
mvn -DskipTests install
我不想诉诸mvn install
作为反对超过here的建议
问候
共 (0) 个答案