解決maven編譯錯誤:程式包com.sun.xml.internal.ws.spi不存在
阿新 • • 發佈:2018-12-14
轉自https://blog.csdn.net/mn960mn/article/details/51253038
當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]
解決方法如下:
新增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
配置好之後,再編譯打包,就沒有問題了