java找不到内部类_(转)maven编译提示找不到sun内部类的解决方法

今天在调整一个系统的构建方式,原先是是用eclipse直接构建的,现在要转换为用maven构建。项目目录结构和项目依赖都配置好之后,命令行下编译却有依赖包找不到的错误。

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] /root/EPMS/src/main/java/com/***/epms/doc/common/DocumentConst.java:[17,66] package com.sun.xml.internal.messaging.saaj.packaging.mime.internet does not exist

[ERROR] /root/EPMS/src/main/java/com/***/epms/doc/common/DocumentConst.java:[144,26] cannot find symbol

symbol  : variable MimeUtility

location: class com.***.epms.doc.common.DocumentConst

[INFO] 2 errors

复制代码

看错误提示,这个依赖包应该是jdk自带的包。用eclipse查找了一下,发现这个包是在rt.jar里面的类。

确认了编译服务器上的JDK环境,rt.jar已经在CLASSPATH里面了,按道理应该能找到这个类的。

在eclipse下直接编译,结果是可以正常编译通过的,为啥在命令行下就没法引用到这个类啊?

后来看到http://maven.40175.n5.nabble.com/Why-can-t-Maven-find-com-sun-xml-internal-messaging-saaj-util-ByteOutputStream-class-td107361.html,才知道问题引起的原因。

Sun's *java compiler* detects when a special

"internal" class is being accessed, and refuses to import the class.

Eclipse uses a different compiler which presumably does not have this check.

Maven just uses the javac compiler available in the system execution

path. Therefore the problem is nothing to do with Maven at all. It's the

compiler that maven is invoking which is refusing to compile the source.

I can't see any public flags in the javac commandline to disable this

"blocking" of internal access, so unless you want to avoid using Sun's

javac compiler you'll just have to avoid using this internal class.

复制代码

用javax包里面的MimeUtility类就可以了

import javax.mail.internet.MimeUtility;

//import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeUtility;

复制代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值