• 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

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

  • 相关阅读:
    每天拿出来2小时浪费(文/王路) 作者: 王路
    objective-c自学总结(二)---init/set/get方法
    objective-c自学总结(一)---面向对象
    水仙花数
    独木舟上的旅行
    阶乘之和
    小明的调查统计
    管闲事的小明
    重温《STL源码剖析》笔记 第一章
    重温《STL源码剖析》笔记 第三章
  • 原文地址:https://www.cnblogs.com/liu-ke/p/7125144.html
Copyright © 2020-2023  润新知