Maven不能编译依赖于rt.jar的类 [英] Maven can't compile class which depends on rt.jar

查看:6422
本文介绍了Maven不能编译依赖于rt.jar的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CI服务器(Hudson),我负责,构建Maven项目。最后一次提交后,生成失败:

CI-server (Hudson), for which I am responsible, builds Maven project. After the last commit, the build failed:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] \hudson\jobs\path to my class\MyClass.java:[33,62] package com.sun.xml.internal.messaging.saaj.packaging.mime.util does not exist
[ERROR] \hudson\jobs\path to my class\MyClass.java:[75,5] cannot find symbol
        symbol  : class BASE64EncoderStream
        location: class |fullname of MyClass|
[ERROR] \hudson\jobs\path to my class\MyClass.java:[75,38] cannot find symbol
        symbol  : class BASE64EncoderStream
        location: class |fullname of MyClass|
[INFO] 3 errors

必需类(com.sun.xml.internal.messaging

Required class (com.sun.xml.internal.messaging.saaj.packaging.mime.util.BASE64EncoderStream) is situated in rt.jar.

我试过(根据 http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies )在项目的pom.xml中添加系统依赖项:

I tried (In accordance with the instructions at http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies) to add system dependency in project's pom.xml:

<dependency>
    <groupId>dummy</groupId>
    <artifactId>dummy</artifactId>
    <version>1</version>
    <scope>system</scope>
    <systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>

没有帮助。

最有趣的是所有文件在我的同事的本地机器上编译良好(他使用Eclipse内置编译器)。

The most interesting is that all files compiled fine on the local machine of my collegue (he use Eclipse build-in compiler).

在互联网我发现同样的问题 http://maven.40175.n5.nabble.com/Why-can-t-Maven-find-com-sun-xml-internal-messaging-saaj-util-ByteOutputStream-class-td107361.html )。最后的答案是,这个麻烦的原因是Oracle的Java编译器。

In internet I found the same question (link: http://maven.40175.n5.nabble.com/Why-can-t-Maven-find-com-sun-xml-internal-messaging-saaj-util-ByteOutputStream-class-td107361.html). The last answer was that the reason for this trouble is Oracle's Java compiler.

所以,我把Oracle的jdk改为OpenJDK,但是没有帮助。

So, I changed Oracle's jdk to OpenJDK, but it did not help.

有人对如何解决这个问题有任何建议吗?

Does someone have any suggestions on how to solve this problem?

推荐答案

似乎是JRE内部(如其命名空间中所示),并且不应从您的代码引用。它可能只适用于特定平台或JRE版本。

The missing class seems to be JRE internal (as indicated in its namespace), and should not be referenced from your code. It is probably only available on specific platforms or JRE versions.

请考虑使用其他Base64编码器类一个来自 Apache Commmons Codec项目

Consider replacing it with another Base64 encoder class, e.g. one from the Apache Commmons Codec project.

这篇关于Maven不能编译依赖于rt.jar的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆