解决maven编译错误:程序包com.sun.xml.internal.ws.spi不存在

当maven项目里面有用到JDK内部的一些类,接口(如:com.sun.xml.internal.ws.spi.ProviderImpl)等的时候,用maven编译一般会出现如下错误

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.105 s
[INFO] Finished at: 2016-04-26T18:45:49+08:00
[INFO] Final Memory: 13M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure
[ERROR] /E:/ide/code/src9/test/src/main/java/com/test/osgi/test/App.java:[7,36] 程序包com.sun.xml.internal.ws.spi不存在
[ERROR] -> [Help 1]
[ERROR]

解决方法如下:

添加maven-compiler-plugin插件,并且配置compilerArguments

如:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
		<source>1.8</source>
		<target>1.8</target>
		<compilerArguments>
			<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
		</compilerArguments>
	</configuration>
</plugin>

注意:

1:这里的rt.jar需要配置正确的路径

2:如果使用的类,接口等在其他的jar里面(如tools.jar),则bootclasspath值需要配置成其他的jar


配置好之后,再编译打包,就没有问题了

  • 8
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 30
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值