解决maven无法编译通过sun内部类,报MojoFailureException异常

     这几天写项目一直都是在自己本地通过idea启动,然后本地测试,没有打包,也没有往服务器发布,并没有发现什么问题,一切正常。今天需要打包一下。忽然在maven install的过程中就出现了如下错误。

[WARNING] The requested profile "dev" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project lls-cloud-product-server: Compilation failure
[ERROR] ���һ��ѭ��: true
[ERROR] D:\develop\code\svnlz\lls\lls-cloud-product-server\src\main\java\com\lenovoedu\product\controller\ProductSolutionsController.java:[10,66] ����: �����com.sun.xml.internal.messaging.saaj.packaging.mime.internet������
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

查了好多资料。有的说是jdk版本不对,换个jdk,就好了。于是乎,就果断换了jdk,然并卵。

最后发现错误信息总是定位到下面这个类。

于是开始从这个类入手,了解到。这是个内部类,当maven项目里面有用到JDK内部的一些类或者接口的时候,用maven编译一般就会报这个异常。看来是找对了方向。

针对这个问题,网上有两种解决方法。

1.不使用这个类,而是用java或者javax中的类来替代。(这种方法我没有尝试)

2.第二种方法(亲测可行)

添加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>
        <compilerArgs>
            <arg>-XDignore.symbol.file</arg>
        </compilerArgs>
        <fork>true</fork>
    </configuration>
</plugin>

另外可以看下这篇文章http://scmroad.com/topics/25883

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值