Java Eclipse:我应该为每个项目创建一个工作区吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2495856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 08:26:23  来源:igfitidea点击:

Eclipse: Should I create a workspace for each project?

javaeclipse

提问by Zombies

I am simply wondering whether it is best to put all of my Eclipse projects into one workspace, or do a 1 workspace per 1 project. I am just a solo developer, for hobby more or less, but the apps I create do actually have production versions that are running on rather frequent cron jobs, so its almost like an amateur production environment.

我只是想知道是否最好将我的所有 Eclipse 项目放入一个工作区中,或者每个 1 个项目做 1 个工作区。我只是一个单独的开发人员,或多或少出于爱好,但我创建的应用程序确实有生产版本,这些版本在相当频繁的 cron 作业上运行,所以它几乎就像一个业余生产环境。

The only problems I have noticed so far is for exporting JARs, I have the potential to include source files from other projects which seems like it could get messy.

到目前为止,我注意到的唯一问题是导出 JAR,我有可能包含来自其他项目的源文件,这似乎可能会变得混乱。

回答by omermuhammed

I create Eclipse workspaces around products, because for me, a product can have multiple projects within them, for example like having core libraries compiled into one jar in a project, this is used by other projects.

我围绕产品创建 Eclipse 工作区,因为对我来说,一个产品中可以有多个项目,例如将核心库编译到一个项目中的一个 jar 中,这被其他项目使用。

In terms of production environment, you would want products running in different directory structures, much cleaner that way. And in eclipse the workspace creates a directory with workspace name. So, create workspaces based on product/app rather than one or more projects within them.

在生产环境方面,您希望产品在不同的目录结构中运行,这样更干净。在 Eclipse 中,工作区会创建一个带有工作区名称的目录。因此,创建基于产品/应用程序而不是其中的一个或多个项目的工作区。

回答by Bryan Denny

I would use separate workspaces for different "groups" of projects. For example you might want to combine your main app project AND the unit testing project together in the same workspace.

我会为不同的“组”项目使用单独的工作区。例如,您可能希望将主应用程序项目和单元测试项目组合在同一个工作区中。

回答by Robin

If the projects are interrelated (i.e. have dependencies on each other) then it quite often makes sense to have them in the same workspace. Also, if you are working on several projects to solve a related problem, the same applies.

如果项目是相互关联的(即相互依赖),那么将它们放在同一个工作空间中通常是有意义的。此外,如果您正在处理多个项目以解决相关问题,这同样适用。

You will waste a lot of time changing workspaces unnecessarily otherwise, especially when the IDE will immediately show you the impact the changes in one project has on another.

否则,您将浪费大量时间不必要地更改工作区,尤其是当 IDE 会立即向您显示一个项目中的更改对另一个项目的影响时。

回答by pugmarx

Up to you! I've always found keeping the related versions of different projects, which belong to the same release in a given workspace a cleaner approach. That way, I could switch between workspaces whenever I need to refer to something in a separate release, and switch back to the current release workspace. It also saves me from the hassle of checking-out, or browsing the repository.

由你决定!我一直发现在给定工作区中保留属于同一版本的不同项目的相关版本是一种更简洁的方法。这样,我可以在需要引用单独版本中的某些内容时在工作区之间切换,然后切换回当前版本工作区。它还使我免于签出或浏览存储库的麻烦。

回答by Rob Goodwin

You may also want to keep in mind that you can open multiple instances of eclipse as long as they are looking at different workspaces. Not sure if that is important to you, but I like doing that from time to time.

您可能还需要记住,只要它们正在查看不同的工作区,您就可以打开多个 eclipse 实例。不确定这对您是否重要,但我喜欢不时这样做。

回答by John

Maybe I'm unlucky, but Eclipse often (once a month, say) dies on startup, typically in the "Initializing Java Tooling" stage. The recommended solution seems to be to create a new workspace. If you have allyour projects in one workspace, this can be a pain. I think smaller workspaces may mean the crash is less likely to occur.

也许我不走运,但 Eclipse 经常(例如,一个月一次)在启动时死掉,通常是在“初始化 Java 工具”阶段。推荐的解决方案似乎是创建一个新的工作区。如果您在一个工作区中拥有所有项目,这可能会很痛苦。我认为较小的工作空间可能意味着不太可能发生崩溃。

回答by Zoltán Ujhelyi

As the Preferences are workspace-specific, I tend to have a enormous workspace open - I'm too lazy to sync some settings between workspaces (e.g. repositories...).

由于首选项是特定于工作区的,我倾向于打开一个巨大的工作区 - 我懒得在工作区之间同步一些设置(例如存储库......)。

On the other having too much projects open in a single workspace can slow down Eclipse - so the least I have to do is to close projects I'm not working with. I manage a lot of relative short-term projects (at most one month) in Eclipse, that reside in the same workspace (and in most cases the same repository), so this setup gives me a bigger flexibility.

另一方面,在单个工作区中打开太多项目会降低 Eclipse 的速度——所以我至少要做的就是关闭我不使用的项目。我在 Eclipse 中管理了很多相对短期项目(最多一个月),它们驻留在同一个工作区(并且在大多数情况下是同一个存储库),所以这种设置给了我更大的灵活性。

If you have several, interrelated projects, then keep them in the same workspace. If you can identify group of projects, that are always used together, but the groups are used independently, then put such project sets into different workspaces. In that case that should be the logical structure.

如果您有多个相互关联的项目,请将它们保存在同一个工作区中。如果您可以识别出始终一起使用的项目组,但这些组是独立使用的,则将这些项目集放入不同的工作区。在那种情况下,这应该是逻辑结构。

回答by ColinD

I used to keep separate workspaces, but got tired of the difficulty in keeping settings consistent between them. Now what I do is create working sets for different projects and change the current window working set to filter out everything except what I want to work on. So far this has worked fine for me.

我曾经保持单独的工作区,但厌倦了在它们之间保持设置一致的困难。现在我要做的是为不同的项目创建工作集并更改当前窗口工作集以过滤除我想要处理的内容之外的所有内容。到目前为止,这对我来说效果很好。

Since each project can have multiple working sets, and the window working set can be any combination of working sets, it's quite easy to only see what you want at any given time this way.

由于每个项目可以有多个工作集,而窗口工作集可以是工作集的任意组合,因此很容易在任何给定时间以这种方式查看您想要的内容。

回答by Thorbj?rn Ravn Andersen

We have a situation where we have several projects, some on branches, which frankly is too impractical to keep in the same workspace - and working sets are a joke. Unfortunately. Also having projects open you do not use, may accidentially be chosen from completion menues, etc. Error prone.

我们有这样的情况,我们有多个项目,其中一些在分支上,坦率地说,将其保留在同一个工作区中太不切实际了 - 而工作集就是一个笑话。很遗憾。也有项目打开你不使用,可能会意外地从完成菜单等中选择。容易出错。

The really nifty feature for us, was when Team -> Project Sets were added (in Eclipse 3.3 I believe) as this allowed us to have a single file describing the many projects making up the whole application, which can be imported in Eclipse with Team->Import. Need a given project? Check it out of CVS, locate the projectSet.psf file inside of it, and import THAT.

对我们来说真正漂亮的功能是添加 Team -> Project Sets 时(我相信在 Eclipse 3.3 中),因为这允许我们拥有一个描述构成整个应用程序的许多项目的单个文件,可以在 Eclipse 中与 Team 一起导入-> 导入。需要一个给定的项目?从 CVS 中检查它,找到其中的 projectSet.psf 文件,然后导入 THAT。

This has proven to work well for us.

事实证明,这对我们很有效。

回答by Rev316

I like to use several decoupled workspaces (which differ depending on the type of project), which importprojects from various locations. Easy to move things around, without creating a ton of similar workspaces. Plays nice with my SCM too.

我喜欢使用几个分离的工作区(根据项目类型的不同而不同),它们从不同的位置导入项目。轻松移动物品,无需创建大量类似的工作空间。和我的 SCM 一起玩也很好。