简体   繁体   English

如何将包从一个项目导入到另一个项目

[英]How to import packages from a project to another

I have two projects (let say project A and project B) the two works with Spring( The same version)the only difference is that the first one has an Eclipse IDE and the second one STS and I want to use and work with the project A in the project B.我有两个项目(比如项目 A 和项目 B),这两个项目与 Spring(相同版本)一起工作,唯一的区别是第一个有 Eclipse IDE,第二个有 STS,我想使用和使用该项目项目 B 中的 A。

I've tried to manually copy/past a number of classes but the classes are so much dependent between them it makes it impossible.我试图手动复制/过去一些类,但这些类之间非常依赖,以至于不可能。

I expect to show me how to import/export project A and use it in project B我希望向我展示如何导入/导出项目 A 并在项目 B 中使用它

Basically project A should be in your build path.基本上项目 A 应该在你的构建路径中。 Any of the two ways works两种方式中的任何一种都有效

  • Export your project A as jar and add the jar to your Project B's build path.将您的项目 A 导出为 jar 并将该 jar 添加到您的项目 B 的构建路径中。
  • Projects BuildPath > Projects > Add your project A.项目 BuildPath > 项目 > 添加您的项目 A。

Basically the one above me is really close , but If you will export project A to jar it might be not work if you want use it on server (Tomcat for example).基本上我上面的那个非常接近,但是如果您将项目 A 导出到 jar,如果您想在服务器(例如 Tomcat)上使用它,它可能无法正常工作。 So you can make it "Runnable jar" from the first place and then as he said : project B (right click) >>>> build path >>>> configuration path >>> libraries >>> add external jar >> and browser when you saved the jar.因此,您可以从一开始就将其设为“可运行 jar”,然后如他所说:项目 B(右键单击)>>>> 构建路径 >>>> 配置路径 >>> 库 >>> 添加外部 jar >> 和保存 jar 时的浏览器。 now you can make instance of projects A classes and the functions already inheritance .现在您可以创建项目 A 类的实例,并且已经继承了这些功能。 glad it helps you :)很高兴它对你有帮助:)

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

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