为什么Maven在安装过程中会忽略更新的类? [英] Why might Maven ignore updated classes during install?

查看:95
本文介绍了为什么Maven在安装过程中会忽略更新的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行war安装时,我一直从Maven 2.2.1安装中看到奇怪的行为.

I've been seeing odd behaviour from my Maven 2.2.1 installation whilst doing war installs.

有时,我将更新一个类,但更新的版本未打包在mvn install产生的工件中.

Occasionally, I will update a class but the updated version is not packaged up in the artifact produced by mvn install.

到目前为止,我已经确定在目标目录中生成了更新的.class文件,并且所生成的.war中具有相同名称的类不相同(修改日期不同,大小不同)

So far, I have determined that an updated .class file is produced in the target directory, and that the class of the same name in the produced .war is not the same (different date modified, different size)

从命令行运行带有-X标志的Maven会为以下类生成调试输出:

Running Maven from the command line with the -X flag produced debug output for the class like:

[DEBUG] * WEB-INF/classes/mypackage/MyClass.class 是最新的.

[DEBUG] * WEB-INF/classes/mypackage/MyClass.class is up to date.

我认为在从Eclipse编译的缓存文件(?)是不完整的地方之前,我也遇到过同样的问题,这导致Maven构建中出现未解决的编译问题"错误,但是Eclipse导出中的工作工件

I think I've also had the same problem before where the file that was cached(?) was an incomplete compile from Eclipse, causing 'Unresolved Compilation Problem' errors from the Maven build, but a working artifact from an Eclipse export.

  • Maven如何确定是否 文件在更新过程中是最新的" 安装过程?
  • Maven正在比较的文件在哪里?
  • 我可以强迫Maven从头开始构建软件包吗?
  • 任何其他想法将不胜感激!
  • How does Maven determine whether a file 'is up to date' during the install process?
  • Where are the files Maven is comparing to?
  • Can I force Maven to build a package from scratch?
  • Any other ideas would be appreciated!

推荐答案

到目前为止,我已经确定 更新的.class文件在 目标目录,并且该类 在产生的.war中具有相同的名称 不一样(不同的日期 修改,大小不同)

So far, I have determined that an updated .class file is produced in the target directory, and that the class of the same name in the produced .war is not the same (different date modified, different size)

可以肯定的是,这些类应该在target\classes而不是target下构建.

Just to be sure, the classes should be built under target\classes, not target.

  • 我可以强迫Maven从头开始构建软件包吗?
  • Can I force Maven to build a package from scratch?

您可以通过运行来强制进行完整构建

You can force a full build by running

mvn clean install

这将在运行安装阶段之前执行clean(实际上是删除target目录).

This performs a clean (essentially removes the target directory) before running the install phase.

也-在Maven构建目录之外检查类的副本.在这种情况下,因为它是一个Web应用程序,请选中src/main/webapp/WEB-INF/classes

Also - check for copies of your classes outside of the Maven build directory. In this case as it is a webapp, check src/main/webapp/WEB-INF/classes

这篇关于为什么Maven在安装过程中会忽略更新的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆