eclipse项目和编译数据

发布于 2024-09-27 01:52:41 字数 143 浏览 2 评论 0原文

在包含 JUnit 测试的 Java Eclipse 项目中,我还有一个包“资源”,其中包含用于测试的所有输入数据。但是在编译 JUnit 测试时,Java 还编译资源中可用的数据,因此我在“bin”文件夹中找到了相同的数据。有办法避免这种情况吗?

谢谢。

in my Java Eclipse project that contains JUnit tests, I also have a package "resource" that contains all input data used for the tests. But when compiling JUnit tests, the Java compile also data available in resources, so I find the same data in the "bin" folder. Is there a way to avoid this?

thanks.

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

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

发布评论

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

评论(1

悲欢浪云 2024-10-04 01:52:41

如果您想要排除源路径中的特定包(例如您的资源文件夹),您可以右键单击该包并选择:Build Path >排除

这将告诉 Eclipse 您不想将该包包含在构建中。

这做出了几个假设:您正在使用 Eclipse Helios(因为旧版本中的选项可能有所不同),并且资源存储在与常规 java 源文件相同的文件夹中(因为如果资源位于文件夹本身,您可以使用构建路径>配置构建路径

更新:

从构建中 删除整个文件夹。关于为什么您愿意或不愿意将资源复制到 bin 目录中:

  • bin 目录的内容应被忽略,并且不应签入版本控制系统(使用 CVS 时,bin 应该是.cvsignore 文件中的条目)
  • 我不确定您是否应该担心这一点。
  • 资源仅在您的本地计算机上复制,该计算机速度快且硬盘很大,如果您使用 <, code>Class.getResource 要访问这些资源,它们需要位于类路径中的某个位置 bin 目录是一个很好的地方

所以,实际上(除了一些未知的,比如文件有数百GB之类的。 ),我认为您不需要担心从构建中排除这些文件。

If you have a particular package within the source path you want to exclude (your resources folder for example), you can right click on the package and select: Build Path > Exclude.

This will tell Eclipse that you don't want to include that package as part of the build.

This is making a couple of assumptions: that you're using Eclipse Helios (because the option might be different in older versions), and that the resources are stored in the same folder as your regular java source files (because if resources is in a folder by itself, you can remove that entire folder from the build by using Build Path > Configure Build Path -> Source tab.

Update:

After the discussion in the comments regarding why you would or would not want to copy resources into the bin directory:

  • The contents of your bin directory should be ignored and not checked into to a version control system (when using CVS, bin should be an entry in the .cvsignore file)
  • The resources are only duplicated on your local machine, which is fast and hard discs are big. I'm not sure you should be worrying about this
  • If you're using Class.getResource to access those resources, they need to be on the classpath somewhere. The bin directory is as good a place as any

So, realistically (barring some unknown, like the files are hundreds of gigabytes or something), I don't think you need to be concerned about excluding these files from the build.

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