简体   繁体   English

仅从另一个 eclipse 项目导入一些包

[英]Import only some packages from another eclipse project

I'm coding in Java with Eclipse.我正在用 Eclipse 用 Ja​​va 编码。 I have two projects: ProjectOne and ProjectTwo .我有两个项目: ProjectOneProjectTwo

I have some packages in ProjectOne that I want to include in ProjectTwo without including anything else from 'ProjectOne'.我在ProjectOne中有一些包,我想将它们包含在ProjectTwo但不包含“ProjectOne”中的任何其他内容。 How can I do that?我怎样才能做到这一点?

You can create one more project projectThree with your needed classes from ProjectOne in it.您可以再创建一个项目 projectThree,其中包含您需要的来自 ProjectOne 的类。 Then ProjectOne and ProjectTwo depend on projectThree.那么 ProjectOne 和 ProjectTwo 依赖于 projectThree。 I think this is best case scenarios now..我认为这是现在最好的情况。

Project Jigsaw which is planned to released in Java 9 should solve your problem.计划在 Java 9 中发布的 Jigsaw 项目应该可以解决您的问题。 it adds modules to Java.. " modules provide a list of all the packages of this particular module that are considered public API and thus usable by other modules. If a class is not in an exported package, no one outside of your module can access it – even if it is public."它将模块添加到 Java.." 模块提供了此特定模块的所有包的列表,这些包被视为公共 API,因此可被其他模块使用。如果某个类不在导出的包中,则模块之外的任何人都无法访问它——即使它是公开的。” More can be found here...(above comment is taken from Below link)更多可以在这里找到......(以上评论来自以下链接)

https://blog.codecentric.de/en/2015/11/first-steps-with-java9-jigsaw-part-1/ https://blog.codecentric.de/en/2015/11/first-steps-with-java9-jigsaw-part-1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM