maven项目编译报错:程序包com.sun.xml.internal.ws.developer不存在
maven项目引入JDK的jar包
·
maven项目如果用到JDK内部的一些类,接口(例如: com.sun.xml.internal.ws.developer.JAXWSProperties)等的时候,用maven编译可能会出现如下错误:
ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/imac/projects/gps/gts/gts-base/src/main/java/xxx.java:[25,41] 程序包com.sun.xml.internal.ws.developer不存在
[INFO] 1 error
这时候需要在编译的时候引入jdk的rt.jar包:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArguments>
<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
如果引用多个jar需要使用;(windows)或者:(macos)来分割,如果这样设置的话,多个平台下开发会很不方便,可以使用变量path.separator代替:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArguments>
<bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)