欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mvn compile報(bào)錯(cuò)“程序包c(diǎn)om.XXX不存在”

 更新時(shí)間:2023年01月16日 16:17:50   作者:super_貝塔  
本文主要介紹了mvn compile報(bào)錯(cuò)“程序包c(diǎn)om.XXX不存在”,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

maven 編譯時(shí)報(bào)錯(cuò):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:
程序包c(diǎn)om.sun.…… 不存在
程序包c(diǎn)om.sun.xml.internal.ws.spi不存在

【官方解釋】:javac uses a special symbol table that does not include all Sun-proprietary classes. When javac is compiling code it doesn't link against rt.jar by default. Instead it uses special symbol file lib/ct.sym with class stubs.大意是:javac在編譯時(shí),并不引用 rt.jar,用的是一個(gè)特別的symbol table(lib/ct.sym),這個(gè)symbol table不包含所有的sun包的類。

【具體原因】:J2SE中的類大致可以劃分為以下的各個(gè)包:java.*,javax.*,org.*,sun.*;除了“sun”包,其它各個(gè)包都是Java平臺的標(biāo)準(zhǔn)實(shí)現(xiàn),并且今后也將被繼續(xù)支持。一般說來,“sun”之類的包并不包含在Java平臺的標(biāo)準(zhǔn)中,它與操作系統(tǒng)相關(guān),在不同的操作系統(tǒng)(如Solaris,Windows,Linux,Mac等等)中的實(shí)現(xiàn)也各不相同,并且可能隨著J2SE版本不定期變化。因此,直接調(diào)用“sun”包的程序代碼并不是100%的Java實(shí)現(xiàn)。也就是說:“sun.*”包并不是API公開接口的一部分,調(diào)用“sun”包的程序并不能確保工作在所有Java平臺上,事實(shí)上,這樣的程序并不能工作在今后的Java平臺上。

【解決方案一】:

<compilerArguments>  
    <verbose />  
    <bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>  
</compilerArguments>  

注意:${JAVA_HOME} 指的是你配置項(xiàng)目依賴的java路徑(jdk版本)
1、如果使用的類,接口等在其他的jar里面(如tools.jar),則bootclasspath值需要配置成其他的jar
2、pom文件如果沒有配置${JAVA_HOME} 導(dǎo)致會報(bào)錯(cuò),也就是說這種方案行不通。

【解決方案二】(親測有效):

<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>
        <encoding>UTF-8</encoding>
        <compilerArgs>
            <arg>-XDignore.symbol.file</arg>
        </compilerArgs>
        <fork>true</fork>
    </configuration>
</plugin>

切記:不要漏掉標(biāo)簽項(xiàng) <fork>true</fork>

【解決方案三】:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
  <configuration>
      <source>${java.version}</source>
      <target>${java.version}</target>
      <encoding>UTF-8</encoding>
      <compilerArguments>
          <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
      </compilerArguments>
  </configuration>
</plugin>

如果還是不行 調(diào)整配置如下:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <groupId>***(其他)***</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

將maven-compiler-plugin配置在后面,插件會覆蓋springboot、其他集成的插件

到此這篇關(guān)于mvn compile報(bào)錯(cuò)“程序包c(diǎn)om.XXX不存在”的文章就介紹到這了,更多相關(guān)mvn compile報(bào)錯(cuò)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論