无法使用MAVEN生成错误-无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.1:compile

nnsrf1az  于 2023-11-17  发布在  Maven
关注(0)|答案(9)|浏览(179)

我一直在尝试使用maven构建一个代码。但是我被一个错误卡住了。代码可以在这个github repo. google-play-crawler上找到
我的系统配置如maven所示如下:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /Users/tushar/Downloads/apache-maven-3.0.5
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"

字符串
以下是错误的Maven跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:862)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


这里是pom.xml。

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.akdeniz</groupId>
    <artifactId>googleplaycrawler</artifactId>
    <version>0.3</version>
    <packaging>jar</packaging>

    <name>Google Play Crawler</name>
    <url>https://github.com/Akdeniz/google-play-crawler</url>

    <description>Play with Google Play API :)</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.argparse4j</groupId>
            <artifactId>argparse4j</artifactId>
            <version>0.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient-cache</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.mina</groupId>
            <artifactId>mina-core</artifactId>
            <version>2.0.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.5.0</version>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.1.1</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <pluginRepositories>
        <pluginRepository>
            <id>protoc-plugin</id>
            <url>http://sergei-ivanov.github.com/maven-protoc-plugin/repo/releases/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <fork>true</fork
                    <executable>${JAVA_1_7_HOME}/bin/javac</executable>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>attached</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <archive>
                                <manifest>
                                    <mainClass>com.akdeniz.googleplaycrawler.cli.googleplay</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.protobuf.tools</groupId>
                <artifactId>maven-protoc-plugin</artifactId>
                <version>0.3.1</version>

                <configuration>
                    <protocExecutable>protoc</protocExecutable>
                    <protoSourceRoot>${project.basedir}/src/main/protobuf/</protoSourceRoot>
                    <languageSpecifications>
                        <LanguageSpecification>
                            <language>JAVA</language>
                            <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                        </LanguageSpecification>
                    </languageSpecifications>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

ymzxtsji

ymzxtsji1#

您的Maven阅读Java版本为1.6.0_65,而pom.xml显示版本为1.7。
尝试安装所需的版本。
如果已经安装,请检查您的$JAVA_HOME环境变量,它应该包含Java JDK 7的路径。如果没有找到,请修复您的环境变量。
也删除线

<fork>true</fork>
     <executable>${JAVA_1_7_HOME}/bin/javac</executable>

字符串
关于pom.xml

fkvaft9z

fkvaft9z2#

对于我的情况,我将“fork”的值切换为false,例如<fork>false</fork>。我不明白为什么。

aemubtdh

aemubtdh3#

我得到了类似的错误,最终发现只是清理构建文件夹解决了我的问题。

mvn clean install

字符串

sirbozc5

sirbozc54#

我遇到了同样的问题。当比较pom.xml文件中提到的java版本时,JAVA_HOMEenv变量指向不同版本的jdk
JAVA_HOMEpom.xml更新到相同的jdk安装路径

ars1skjm

ars1skjm5#

如果安装了JDK,但仍然无法工作。
在Eclipse中执行以下步骤:- Window --> Preference --> Installed JRE-->Change path of JRE to JDK(添加)。

8tntrjer

8tntrjer6#

即使设置了正确的JAVA-Version和JAVA_HOME变量,我也遇到了同样的问题。(在我的情况下是Java 11)。

切换到另一个Java-Vendor从OpenJDK切换到Corretto解决了这个问题。

您可以使用SDKMAN轻松快速地在不同的Java版本和供应商之间进行更改。(JAVA_HOME变量将由SDKMAN自动设置正确)。

SDKMAN安装方式

curl -s "https://get.sdkman.io" | bash

字符串
然后在终端中输入:

source "$HOME/.sdkman/bin/sdkman-init.sh"


确保安装成功:

sdk version

安装Java 7:

sdk install java 7.0.322-zulu
sdk default java 7.0.322-zulu


检查版本、运行时和供应商:

java --version
mvn -v

dauxcl2d

dauxcl2d7#

对我来说,我把C:\apps\Java\jdk1.8_162\bin\javac.exe改成了C:\apps\Java\jdk1.8_162\bin\javacpl.exe,因为bin文件夹中没有这个名字的可执行文件。

zu0ti5jz

zu0ti5jz8#

对我来说,这一招奏效了
我必须从任务管理器结束Java任务,因为它无法清理。
再次重建它,它工作了。
注:我使用的是windows系统。


的数据

ryevplcw

ryevplcw9#

我也遇到过类似的例外。在这里发帖,以防将来对某人有帮助。我的SpringBoot应用程序正在从application.yml文件中查找属性。但我从一个看起来很像application.properties文件的文件中复制粘贴了属性。请记住,这两个文件的格式不一样。

相关问题