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: 2017-07-05T12:45:49+08:00
[INFO] Final Memory: 21M/219M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure
[ERROR] /C:/Users/Administrator/Desktop/lk/src/main/java/com/lk/Test.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.7</source>
        <target>1.7</target>
        <compilerArguments>
            <bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
        </compilerArguments>
    </configuration>
</plugin>

注意:

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

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

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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM