如何正确地对Java项目(Maven、Spring)进行版本控制(svn:ignore)?

发布于 2024-11-15 02:20:09 字数 565 浏览 5 评论 0原文

我参加了为期 2 天的 Java EE 培训培训。我们使用了 Java EE、Spring Framework、Maven、Springsource Tool Suite (Eclipse)、Tomcat。

我在那里创建了 Eclipse 工作区并在我的工作 PC 上运行它。如果我没记错的话,我只需要正确配置 Tomcat,它就可以在我的 PC 上运行。

现在我想在 subversion 中保存创建的包含 5 个“子”项目的 Eclipse 工作区,以便我的同事可以将其签出给他们并在他们的计算机上运行它。

如何正确地做到这一点?我在某处发现了一个 svn:ignore 规则:

.classpath
.project
.settings
target

使用 tortoiseSVN 我将这个忽略规则添加到了工作区的文件夹中,但发现底层文件夹目标没有被删除,所以我手动删除了它们并“添加到忽略列表”。但之后 spring 源工具套件中的项目看不到 mevan 依赖项(我认为是这样),因为导入已损坏。 STS 强调组织。在进口中并表示无法解决此问题。

我如何正确地控制这样的项目?

i was on a 2-day training introducing as to Java EE. We used there Java EE, Spring Framework, Maven, Springsource Tool Suite (Eclipse), Tomcat.

I took the Eclipse workspace we created there and run it on my work PC. I had, if i remember correctly, only to configure Tomcat properly, and it worked on my PC.

Now i want to save the created Eclipse workspace containing 5 "sub"-projects in subversion so that my work colleagues can checkout this to them and run it on their computers.

How to do this correctly? I found somewhere a svn:ignore rule:

.classpath
.project
.settings
target

Using tortoiseSVN i added to the folder with the workspace this ignore rule, but the found out that the underlying folders target were'nt deleted so i deleted them manually and "added to ignore list". But after that the project in spring source tool suite does not see the mevan dependencies (i think so) because the imports are broken. STS underlines org. in the imports and says it can not resolve this.

How do i correctly version control such a project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

路弥 2024-11-22 02:20:09

在我的项目中,我们使用 Maven 和 Eclipse(当前为 Helios)以及 Eclipse 的 Maven 插件:

Maven Integration for Eclipse
WTP 的 Maven 集成

我们的版本控制系统中只有 pom.xml 文件和 src/ 目录树。我们确保在那里添加 eclipse 文件。然后,当新开发人员开始项目时,他们会执行“导入”->“导入”。 Maven->现有 Maven 项目。然后,Eclipse 的 Maven 插件会设置完美的构建路径、设置等。

这样,根据需要将项目重新导入 Eclipse 也非常容易。

因此,我的建议是将 Eclipse 文件保留在 SVN 之外,并确保您只需导入 Maven 项目即可自动正确设置项目。

In my project we are using Maven and Eclipse (Helios, currently) and the Maven plugins for Eclipse:

Maven Integration for Eclipse
Maven Integration for WTP

We only have the pom.xml file and the src/ directory tree in our version control system. We make sure not to add the eclipse files there. Then when a new developer starts in the project they do Import -> Maven -> Existing Maven Projects. The Maven plugins for Eclipse then set up perfect build paths, settings and so on.

This way it is also very easy to re-import your projects into Eclipse as needed.

So, my tip is to leave the Eclipse files out of SVN and make sure you can setup the project correctly automatically simply by importing a Maven project.

颜漓半夏 2024-11-22 02:20:09

如果我正确理解您的问题,您需要配置 Eclipse 才能从中启动 tomcat。我认为,这里的关键不再是 Maven,而是 Eclipse。由于您在工作区中进行了无法放入 Maven 配置文件(pom.xml)中的修改,因此您将成为“Eclipse 依赖者”。

这里的关键是,由于您依赖于 Eclipse,因此需要 Eclipse 配置文件才能工作。因此,恐怕您需要将 .classpath.project.settings 添加回您的版本控制工具...它不是通用的,因为您强迫从事您项目的人员使用 Eclipse。但如果团队中的每个人都这样做,那就不成问题了。

由于我不再使用 Eclipse,我不知道对这些文件进行版本控制是否会导致问题。但是,我希望这个答案将帮助您重新配置您的项目...

编辑:更准确...并且也许给出更好的答案。

当使用版本控制系统时,主要目标通常(总是?)提供使用源代码并从中进行开发的所有密钥。因此,您需要将源代码以及有效使用它们所需的所有配置放入 VCS 中。

在您的具体情况下,关键是您已经通过其 Springsource Tool Suite 插件变得依赖于 Eclipse。因此,为该工具添加配置文件变得至关重要,因为没有这些配置文件就无法工作,如果它们无法工作,您就无法工作。

If I understand your problem the right way, you need to configure Eclipse in order to be able to launch tomcat from it. The key, here, is not maven anymore, but Eclipse, I think. As you've made modifications in your workspace that can't be put in your maven configuration file (the pom.xml), you become "Eclipse dependant".

The key here is that, as you're Eclipse dependant, you need the Eclipse configuration files to work. Consequently, I'm afraid you need to add back .classpath, .project, .settings to your versioning tool... It's not generic, because you force people who work on your project to use Eclipse. But if everybody in your team do so, it shouldn't be a problem.

As I don't use Eclipse anymore, I don't know if versioning theses files can lead to problems. However, I hope this answer will help you to configure your project back...

EDIT : to be more accurate... and maybe give a better answer.

When using a version control system, the main goal is often (always ?) to give all the keys to use the sources, and develop from them. Consequently, you need to put in your VCS your sources, and all the configurations needed to use them efficiently.

In your specific case, the key is that you've become Eclipse dependant through its Springsource Tool Suite plugin. Consequently, it becomes essential to add the configuration files for this tool, because they can't work without them, and if they can't work, you can't work.

如梦 2024-11-22 02:20:09

我可以告诉你我颠覆maven eclipse项目的方法。 首先,当您创建项目结构时,您必须提交 .setting、.classpath、.project 文件到 Subversion 存储库中。如果您做不到这一点,其他同事在结账后将无法使用该项目结构。提交项目结构后,最好的方法是不要提交这些文件,除非您更改了一些重要的 eclipse 或构建路径设置,因为其他文件会因系统相关信息而产生冲突。 永远不要提交maven目标目录。对不起我的英语。希望有帮助。

I can tell you my way of subversioning maven eclipse projects. First, when you create the project structure you have to commit the .setting, .classpath, .project files into the subversion repository. If you can't do this the other colleagues will can not use the project structure after checkout. After you commit the project structure, the best way is not to commit these files except only when you change something important eclipse or build path settings, because the others will have conflicts due to the system dependent informations. Never commit the maven target directory. Sorry for my english. Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文