天天看點

maven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspatmaven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspat

maven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspat

問題:jenkins搭建maven項目部署時報

Fatal Error: Unable to find package java.lang in classpath or bootclasspat
incrementalBuildHelper#beforeRebuildExecution      

但是,在本地開發環境idea部署時沒有任何問題,初步懷疑是環境問題

網上解決辦法

在網上看到的解決辦法大多數是增加

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>${jdk.version}</source>
          <target>${jdk.version}</target>
          <compilerArguments>
            <bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
          </compilerArguments>
          <showWarnings>true</showWarnings>
          <encoding>utf8</encoding>
        </configuration>
      </plugin>      

但是對比自己項目發現已經設定過且之前部署沒有問題,後再次回歸環境問題的排查

解決

通過檢視jenkins調用maven打包部署時的日志

clean compile package -Dmaven.test.skip=true -X -e        

發現,在尋找rt.jar包時一直無法找到,後更改jenkins部署配置,指定具體的jdk版本

maven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspatmaven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspat
maven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspatmaven 打包項目報Fatal Error: Unable to find package java.lang in classpath or bootclasspat

如上:便解決了我這邊在jenkins打包報Fatal Error: Unable to find package java.lang in classpath or bootclasspat 這個錯誤的問題,大家可以作為參考