如果从命令提示符执行 mvn clean 命令,则 mvn package 命令不会成功运行
你好 执行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
错误消息给出了提示:
The error messages gives the hint:
正如其他发帖者已经开始指出的那样,您正在尝试编译符合语言级别 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.
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.