简体   繁体   English

无法执行目标 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli)

[英]Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli)

I just started to learn spring boot.刚开始学spring开机。 I only coded a simple hello world program but whatever i try i can't fix this problem.我只编写了一个简单的 hello world 程序,但无论我尝试什么,我都无法解决这个问题。

There is my pom file:有我的 pom 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Here is the log:这是日志:


cd C:\Users\sedat\Documents\NetBeansProjects\InitializrSpringbootProject; "JAVA_HOME=C:\\Program Files\\Java\\jdk-14.0.2" cmd /c "\"C:\\Program Files\\NetBeans-14\\netbeans\\java\\maven\\bin\\mvn.cmd\" -Dexec.vmArgs= \"-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}\" \"-Dexec.executable=C:\\Program Files\\Java\\jdk-14.0.2\\bin\\java.exe\" -Dexec.mainClass=com.example.demo.DemoApplication -Dexec.classpathScope=runtime -Dexec.appArgs= \"-Dmaven.ext.class.path=C:\\Program Files\\NetBeans-14\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec"
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...

--------------------------< com.example:demo >--------------------------
Building demo 0.0.1-SNAPSHOT
--------------------------------[ jar ]---------------------------------

--- exec-maven-plugin:3.0.0:exec (default-cli) @ demo ---
Error: LinkageError occurred while loading main class com.example.demo.DemoApplication
    java.lang.UnsupportedClassVersionError: com/example/demo/DemoApplication has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 58.0
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  0.853 s
Finished at: 2022-12-08T16:29:21+03:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project demo: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I've tried to add main class and some plugins to the pom file but none of them seem to worked.我尝试将 main class 和一些插件添加到 pom 文件中,但它们似乎都不起作用。 And i changed the java version on pom but that didn't work either.我在 pom 上更改了 java 版本,但这也不起作用。

The issue is java version.问题是java版本。 You are using Java 8 with Spring Boot 3.0.0 and that is incorrect because Spring Boot 3.0.0 only supports Java 17. So there are two ways to fix the problem.您将 Java 8 与 Spring Boot 3.0.0 一起使用,这是不正确的,因为 Spring Boot 3.0.0 仅支持 Java 17。因此有两种方法可以解决此问题。

  1. Upgrade Java version from 8 to 17 and try again.将 Java 版本从 8 升级到 17,然后重试。
  2. Use old version of Spring Boot ie 2.7.6 and try again.使用旧版本的 Spring Boot ie 2.7.6 再试一次。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么? ... 未能执行目标 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) - Why? … Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) 无法在 NetBeans 中执行目标 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) 的问题 - Promblem with Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) in NetBeans 无法在项目上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli):命令执行失败 - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project: Command execution failed 无法在项目SpringData上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli) - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project SpringData 无法在项目上执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:java(default-cli) <project-name> : - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project <project-name>: 我尝试运行我的Maven项目时遇到错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli) - I have an error when i trying to run my maven project: Failed execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) JAVA如何修复错误&gt;无法在项目Sic桌面上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli): - JAVA how to fix error> Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project sic-desktop: 无法在项目 nextrtc-signaling-serverrror 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) on project nextrtc-signaling-serverrror Maven错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Maven error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec Smooks-无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Smooks - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM