Eclipse 什么时候将资源复制到输出文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3254768/
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
When does Eclipse copy resources to the output folder?
提问by Stroboskop
I noticed that "sometimes" the resources i put into a source folder in my Eclipse project will not be copied to the output folder ("bin") immediately.
E.g. i change a properties file using the eclipse editor and save... and "bin" still has the old version.
我注意到“有时”我放入 Eclipse 项目中的源文件夹中的资源不会立即复制到输出文件夹(“bin”)。
例如,我使用 eclipse 编辑器更改了一个属性文件并保存...而“bin”仍然具有旧版本。
Does anyone know what exactly triggers the copying (and how i can trigger that from a plugin)? I thought it happened automatically when a resource changes.
有谁知道究竟是什么触发了复制(以及我如何从插件触发它)?我认为当资源发生变化时它会自动发生。
-- EDIT --
- 编辑 -
To clarify what i meant by triggering it from a plugin: I have a plugin that depends on up to date resources in the output folder, but apparently the resources are outdated when my plugin is called. And that's why i need to better understand what happens and how i can force it when i need to.
为了澄清我从插件触发它的意思:我有一个插件依赖于输出文件夹中的最新资源,但显然当我的插件被调用时资源已经过时了。这就是为什么我需要更好地了解会发生什么以及在需要时如何强制执行。
采纳答案by jamesqiu
This is a Bugin almost all Eclipse versions, it happens without any reason. My eclipse 3.5.2 and 3.6.2 both meet this problem in someday. In my case, I need to copy modified .clj clojure source files to classes directory for immediate effection in a web app, now I have to set /src before /classes in CLASSPATH of web appserver startup script, It's solve my problem temporarily.
这是几乎所有 Eclipse 版本中的一个Bug,它的发生是没有任何原因的。我的 eclipse 3.5.2 和 3.6.2 总有一天会遇到这个问题。就我而言,我需要将修改后的 .clj clojure 源文件复制到 classes 目录以在 web 应用程序中立即生效,现在我必须在 web appserver 启动脚本的 CLASSPATH 中的 /classes 之前设置 /src,它暂时解决了我的问题。
回答by Thirler
If you don't add the resource through eclipse (but for instance through the windows explorer), eclipse wont notice some changes until you refresh your project/folder. (right click in the packater explorer for instance).
如果您不通过 eclipse(但例如通过 Windows 资源管理器)添加资源,则在您刷新项目/文件夹之前,eclipse 不会注意到某些更改。(例如,右键单击打包器资源管理器)。
After it notices the change it will copy it to the output folder when you build (often this is done automatically upon changes)
在它注意到更改后,它会在您构建时将其复制到输出文件夹(通常这会在更改时自动完成)
回答by Gilson Araujo
As @Thirler said, if you don't add the resource through Eclipse, it may not notice the files until you refresh your project. However, if the Refresh/Clean doesn't work (in my case, it didn't), you have to add the files to the folder structure IN ECLIPSE.
正如@Thirler 所说,如果您不通过 Eclipse 添加资源,则在您刷新项目之前,它可能不会注意到这些文件。但是,如果刷新/清理不起作用(在我的情况下,它不起作用),您必须将文件添加到 ECLIPSE 中的文件夹结构中。
Just drag the file from the folder where it is in the file system using Finder/Windows Explorer, drop it into the same folder in Eclipse's Project Explorer (Eclipse will ask for overwriting, just say yes) and Voila!
只需使用 Finder/Windows 资源管理器从文件系统中的文件夹中拖动文件,将其放入 Eclipse 项目资源管理器中的同一个文件夹中(Eclipse 会要求覆盖,只需说是),瞧!
EDIT: An easier way is to just navigate into the folder using Project Explorer and then Refresh (F5).
编辑:一种更简单的方法是使用项目资源管理器导航到文件夹,然后刷新 (F5)。
回答by Andrei Fierbinteanu
As far as I know it happens when you build the project. You don't need a plug-in, you just need to tell eclipse to do a build of the project.
据我所知,当您构建项目时会发生这种情况。您不需要插件,您只需要告诉 eclipse 进行项目的构建。