如果从命令提示符执行 mvn clean 命令,则 mvn package 命令不会成功运行

发布于 2024-10-30 08:53:30 字数 2904 浏览 2 评论 0原文

你好 执行 mvn clean 命令后从命令行运行 mvn package 命令时出现奇怪的错误。 该错误是编译失败错误。

这是一条痕迹:

annotations are not supported in -source 1.3
06.04.2011 17.06.59 (use -source 5 or higher to enable annotations)
06.04.2011 17.06.59 @Override at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
06.04.2011 17.06.59 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
06.04.2011 17.06.59 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
06.04.2011 17.06.59 at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
06.04.2011 17.06.59 at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
06.04.2011 17.06.59 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06.04.2011 17.06.59 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
06.04.2011 17.06.59 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
06.04.2011 17.06.59 at java.lang.reflect.Method.invoke(Method.java:597)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
06.04.2011 17.06.59 Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
06.04.2011 17.06.59 at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
06.04.2011 17.06.59 at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
06.04.2011 17.06.59 at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)

奇怪的是,当我从 eclipse IDE /m2eclipse 运行 mvn package 命令时,它工作得很好(即使在从 IDE 和命令提示符运行 mvn clean 之后)。当我从命令提示符运行 mvn package 命令,并且已经通过之前的 mvn package 命令在目标文件夹中构建了 WAR 文件时,该命令工作正常,并且创建了一个 war 文件,并覆盖了目标文件夹中先前创建的 war 文件。但是,当我从 IDE/命令提示符运行 mvn clean,然后从命令提示符运行 mvn package 时,它​​会出现上述错误,并且编译失败。 我想自动化此构建过程,因此我需要从命令行完成此操作。

Hi
I get a weird error when I run mvn package command from the command line after executing mvn clean command.
The error is a compilation failure error.

This is a trace:

annotations are not supported in -source 1.3
06.04.2011 17.06.59 (use -source 5 or higher to enable annotations)
06.04.2011 17.06.59 @Override at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
06.04.2011 17.06.59 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
06.04.2011 17.06.59 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
06.04.2011 17.06.59 at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
06.04.2011 17.06.59 at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
06.04.2011 17.06.59 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06.04.2011 17.06.59 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
06.04.2011 17.06.59 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
06.04.2011 17.06.59 at java.lang.reflect.Method.invoke(Method.java:597)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
06.04.2011 17.06.59 at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
06.04.2011 17.06.59 Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
06.04.2011 17.06.59 at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
06.04.2011 17.06.59 at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
06.04.2011 17.06.59 at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
06.04.2011 17.06.59 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)

The strange thing is when I run mvn package command from eclipse IDE /m2eclipse it works perfectly fine (Even after running mvn clean from IDE as well as command prompt). when I run mvn package command from command prompt with the WAR file already built in the target folder by previous mvn package command the command works fine and a war file gets created and gets overwritten on the previously created war file in the target folder. But when I run mvn clean from IDE/Command prompt and then run mvn package from command prompt it gives me the above error and the compilation fails.
I want to automate this build process so I need to get this done from command line.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千寻… 2024-11-06 08:53:30

错误消息给出了提示:

使用 -source 5 或更高版本来启用
注释
您必须配置编译器插件以至少使用 Java 1.5 进行编译。

The error messages gives the hint:

use -source 5 or higher to enable
annotations
You have to configure the Compiler plugin to use at least Java 1.5 for compiling.

似梦非梦 2024-11-06 08:53:30

正如其他发帖者已经开始指出的那样,您正在尝试编译符合语言级别 5 (Java 5) 的代码(它使用注释),但您的编译器设置设置为语言级别 1.3。

请参阅 设置 -source 和 - maven-compiler-plugin 页面上 Java 编译器的目标

As other posters have started to point out, you're attempting to compile code that is language level 5 (Java 5) compliant (it uses annotations), but your compiler settings are set for language level 1.3.

See Setting the -source and -target of the Java Compiler on the maven-compiler-plugin's page.

分開簡單 2024-11-06 08:53:30

Eclipse maven 插件还安装了 Maven(核心)的另一个副本。因此,通过 eclipse VS 命令行运行 Maven 命令时,几乎没有什么事情会有所不同。为了摆脱这种情况,请将 Eclipse 配置为使用您希望它使用的 Maven 安装。窗口-->偏好设置 --> Maven-->安装并更改设置以指向您已下载的本地副本。

Eclipse maven plugin also installs another copy of Maven (core). So, few of things would work differently while running maven command through eclipse VS Command line. To get away from this situation configure your eclipse to use maven installation you're expecting it to use. Window --> Preferences --> Maven--> Installations and change the setting to point to the local copy you've downloaded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文