maven编译时报错:致命错误: 在类路径或引导类路径中找不到程序包 java.lang

2022-12-02 10:52:15 浏览数 (1)

maven编译时报错:致命错误: 在类路径或引导类路径中找不到程序包 java.lang:

代码语言:javascript复制
 [INFO] -------------------------------------------------------------
 [ERROR] COMPILATION ERROR : 
 [INFO] -------------------------------------------------------------
 [ERROR] An unknown compilation problem occurred
 [INFO] 1 error
 [INFO] -------------------------------------------------------------
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD FAILURE
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 2.078 s
 [INFO] Finished at: 2016-08-02T23:43:33 08:00
 [INFO] Final Memory: 16M/217M
 [INFO] ------------------------------------------------------------------------
 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project weixin_project: 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版本或者JDK版本引入混乱导致的

解决方法: 在maven的配置文件pom.xml中,把

代码语言:javascript复制
  <bootclasspath>${java.home}/rt.jar;${java.home}/jce.jar</bootclasspath> 

注释即可

代码语言:javascript复制
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.0</version>
 <configuration>
 <source>1.7</source>
 <target>1.7</target>
 <encoding>UTF-8</encoding>
 <compilerArguments>
 <verbose />
 <!-- <bootclasspath>${java.home}/rt.jar;${java.home}/jce.jar</bootclasspath> -->
 </compilerArguments>
 </configuration>
 </plugin>
 <plugin>

直接在pom文件中搜索bootclasspath

0 人点赞