一些執行maven命令的報錯

wdgde發表於2024-07-16

1.mvn clean --settings ./settings.xml

[ERROR] Could not create local repository at /github/workspace/repository -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/LocalRepositoryNotAccessibleException

需要註釋掉settings.xml檔案中的localRepository配置

<!--  <localRepository>/github/workspace/repository/</localRepository>-->

2.mvn clean

[ERROR] Failed to execute goal on project xxx-build: Could not resolve dependencies for project com.xxx.xxx:xxx-build:pom:1.0.0-SNAPSHOT: The following artifacts could not be resolved: com.xxx.xxx:xxx-server-wdd-engine:jar:1.0.0-SNAPSHOT (absent),com.xxx.xxx:xxx-wdd-engine-connector-influxdb-side:jar:1.0.0-SNAPSHOT (absent): com.xxx.xxx:xxx-server-wdd-engine:jar:1.0.0-SNAPSHOT was not found in https://xxx.xxx.xxx.xxx:8080/artifactory/xxx during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of wdd-devops has elapsed or updates are forced -> [Help 1]

需要把pom.xml裡面的goals註釋掉,暫不清楚什麼原因

        <build>
                <plugins>
                    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-antrun-plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>clean</id>
                                <phase>clean</phase>
                                <goals>
                                    <!-- <goal>run</goal> 註釋這行,不然mvn clean會報錯。但是註釋掉再執行mvn clean就不會刪打包好的包了-->
                                </goals>
                                <configuration>
                                    <target>
                                        <delete dir="${project.basedir}/xxxxxxx"/>
                                    </target>
                                </configuration>
                            </execution>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <!---->
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

3.mvn clean package -pl xxxx -am --settings ./settings.xml

Caused by: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x248b2b61) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x248b2b61

這個是因為本地的java環境變數沒配好,需要jdk1.8版本。

透過java -version檢視當前版本

相關文章