这也发生在我身上,这里给出的答案已经不令人满意,所以我做了自己的研究。
背景:Eclipse 访问限制
Eclipse具有一种称为访问限制的机制,可防止你意外使用Eclipse认为不属于公共API的类。通常,从两种意义上讲,Eclipse都是正确的:我们通常不想使用不属于公共API的内容。Eclipse通常对公共API的组成部分是正确的是正确的。
问题
现在,在某些情况下,你想使用公共Non-API,例如
sun.misc(你不应该,除非你知道自己在做什么)。在某些情况下,
Eclipse并不是真的正确(这就是发生在我身上的事情,我只是想使用
javax.smartcardio)。在这种情况下,我们会在
Eclipse中收到此错误。
解
解决方案是更改访问限制。
- Go to the properties of your Java project,
- i.e. by selecting “Properties” from the context menu of the project in the “Package Explorer”.
- Go to “Java Build Path”, tab “Libraries”.
- Expand the library entry
- select
- “Access rules”,
- “Edit…” and
- “Add…” a “Resolution: Accessible” with a corresponding rule pattern. For me that was “javax/smartcardio/”, for you it might instead be “com/apple/eawt/”.



