maven打包报错:在类路径或引导类路径中找不到程序包 java.lang

时间:2022-05-09 09:30:11

  刚下了个新项目,跑了下maven报错了:

E:\workspace\portalframe>mvn clean install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.migu.reading.portalFrame:ues:war:trunk-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.portalFrame:commons.mq:jar -> duplicate declaration of version V300R003C20B311 @ line 1031, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.portalFrame:axis:jar -> version 0.0.1 vs 1.4 @ line 1164, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.portalFrame:com.huawei.uxe.core.render:jar -> version 3.2.21.22 vs 0.0.1 @ line 1230, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.portalFrame:commons-codec:jar -> duplicate declaration of version 1.3.2 @ line 1483, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.portalFrame:jdom:jar -> version 1.1 vs 0.0.1 @ line 1982, column 17
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 2915, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ues trunk-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ues ---
[INFO] Deleting E:\workspace\portalframe\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ues ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 352 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ues ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4791 source files to E:\workspace\portalframe\target\classes
致命错误: 在类路径或引导类路径中找不到程序包 java.lang
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.730 s
[INFO] Finished at: 2019-01-25T11:37:58+08:00
[INFO] Final Memory: 40M/637M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ues: Compilation failure
[ERROR] An unknown compilation problem occurred
[ERROR] -> [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/MojoFailureException

  既然是编译错误,那么就考虑下jdk包问题,去看了下pom.xml,发现插件里有这个东西:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>UTF-8</encoding>
          <optimize>false</optimize>
          <debug>false</debug>
          <showDeprecation>false</showDeprecation>
          <showWarnings>true</showWarnings>
          <compilerArguments>
           <bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar</bootclasspath>
          </compilerArguments>
        </configuration>
      </plugin>

  看到bootclasspath就觉得很奇怪,为啥是个冒号来分割呢?一查才知道,冒号是用于linux操作系统的,windows下只能改为分号。改完重新跑maven,这次不再出现该问题了。