Eclipse 中 maven-archetype-webapp 中的目标目录是什么,我应该将它添加到 .gitignore 中吗?

What is target directory in maven-archetype-webapp in Eclipse and shall I add it to .gitignore?

这是我在 Eclipse 中的示例 Maven 动态 Web 项目 (maven-archetype-webapp)。

哪些文件夹应从 git 中排除(即添加到 .gitignore)?

我曾经认为 Maven 中的目标文件夹意味着编译的 .class 文件并且永远不需要 committed/pushed - 所以我想将整个 target/ 添加到 .gitignore - 因为我不想在 git 回购中使用 maven-fetched jar。但问题是,它会忽略我的 index.jsp(以及其他要添加的 jsp/html 文件)和 web.xml!

除了目标文件夹包含 MyListener.java,而不是 MyListener.class!

并且目标文件夹不包含 Student.java 或 Student.class(此 class 在 MyListener.java 中使用 Spring ClassPathXmlApplicationContext 作为 Student student = (Student) context.getBean("student"); )

P.S。 Deployed Resources文件夹的内容是这样的:

Maven docs:

There are just two subdirectories of this structure: src and target.

The target directory is used to house all output of the build.

P.S。 我将目标添加到 .gitignore 并且项目已安全克隆并在另一台机器上构建!所以 - 解决了!

正如文档所说,目标目录中有 class 个文件、jar 和其他输出文件。 它们是自动生成的,只会提交垃圾邮件。

从那以后,您应该将 target 目录添加到您的 .gitignore

[提示]

使用 gitignore.io 生成您的 .gitignore