简体   繁体   English

Maven / M2Eclipse一直排除我的资源

[英]Maven / M2Eclipse excludes my resources all the time

I have two very annoying issues with Maven-Eclipse integration, from time to time it excludes all my resources in src/main/resources and src/test/resources from the build path. 我有两个非常烦人的Maven-Eclipse集成问题,它不时地从构建路径中排除src / main / resources和src / test / resources中的所有资源。

If I inspect "Properties >> Java Build Path >> Source" I can see that these two folders have "Excluded: **". 如果我检查“属性>> Java构建路径”源“我可以看到这两个文件夹有”排除:**“。

The problem can be easily solved by clicking on "Remove" on the exclusions, but it is really-really frustrating. 通过单击排除项中的“删除”可以轻松解决问题,但这确实非常令人沮丧。

The project setup is very simple, it has some modules and sub-modules, but nothing fancy. 项目设置非常简单,它有一些模块和子模块,但没什么特别的。 I don't have any configuration options in my pom.xmls regarding resources, eclipse or whatever (maybe I should?). 我的pom.xmls中没有关于资源,eclipse或其他任何配置选项(也许我应该这样做)。

The other problem is that Eclipse keeps reporting warnings in the "target" directories (in the "Problems" view), where it shouldn't give a damn in the first place. 另一个问题是Eclipse不断在“目标”目录中报告警告(在“问题”视图中),它首先不应该给出一个该死的。

Ps: Springsource Tool Suite 2.7.0.RELEASE, Maven Integration for Eclipse 0.12.1.20110112, Maven 2.2.1 Ps:Springsource Tool Suite 2.7.0.RELEASE,Eclipse的Maven Integration 0.12.1.20110112,Maven 2.2.1

This is correct behavior. 这是正确的行为。 Current version of M2E provide their own contributor to the automatic build process inside the Eclipse IDE. 当前版本的M2E为Eclipse IDE中的自动构建过程提供了自己的贡献。 This build process takes into account the maven lifecycle for generate-resources and process-resources etc... ie some project have plugins that generate resources from configuration and put in the compiled output folder. 此构建过程考虑了生成资源和流程资源等的maven生命周期...即,某些项目具有从配置生成资源并放入已编译的输出文件夹中的插件。

The mechanism you are looking at in the Build Path only relates to the Eclipse IDEs built in mechanism to compile/assembly a set of input source folders into the output folders. 您在构建路径中查看的机制仅与构建在机制中的Eclipse IDE相关,该机制用于将一组输入源文件夹编译/组装到输出文件夹中。 If both Maven and Eclipse did this there would be conflicts/problems. 如果Maven和Eclipse都这样做会有冲突/问题。

There is a link in the M2E FAQ about this exact point https://www.eclipse.org/m2e/documentation/m2e-faq.html#how-to-configure-proxy-and-location-of-maven-local-repository M2E FAQ中有一个关于这个确切点的链接https://www.eclipse.org/m2e/documentation/m2e-faq.html#how-to-configure-proxy-and-location-of-maven-local-知识库

If you are genuinely having problems with resources not being copied maybe we can work through why that is (since that is another matter), but your main question is about a common M2E FAQ point. 如果您真的遇到资源未被复制的问题,我们可以解决为什么会这样(因为这是另一回事),但您的主要问题是关于常见的M2E FAQ点。

Maybe you want to upgrade to org.eclipse.m2e and Indigo as a lot of Maven complex maven issues/usage I have are mostly resolved or have an explained solution. 也许你想升级到org.eclipse.m2e和Indigo,因为很多Maven复杂的maven问题/用法我大多已经解决或者有解释的解决方案。

.

I would recommend you perform a "Run As -> Maven -> clean" and then a "Project -> Clean" then enable automatic bulding (this is to allow Eclipse based automatic build to take place, do not use Run As -> Maven to build to test this point). 我建议你执行一个“Run As - > Maven - > clean”然后执行“Project - > Clean”然后启用自动bulding(这是为了允许基于Eclipse的自动构建,不要使用Run As - > Maven建立测试这一点)。 Now open a file manager outside eclipse and manually inspect the output folders for the resources that you did not think are being copied. 现在在eclipse外面打开一个文件管理器,并手动检查输出文件夹中是否有你认为没有被复制的资源。 You should find they are there just the same. 你会发现它们在那里是一样的。

.

I agreed with the (probably Validation) warning about items in the target/** directory and whilst Eclipse has a way to manually exclude the target/** directory from validation this option does not stick beyond a project clean (when the target directory is deleted). 我同意关于目标/ **目录中项目的(可能验证)警告,虽然Eclipse有办法从验证中手动排除目标/ **目录,但这个选项不会超出项目清理范围(当目标目录是删除)。

So it is somewhat annoying to be always waiting for validation of items in a large project. 因此总是等待大型项目中的项目验证有点烦人。

Maybe I attempt to see if a Maven Eclipse connector plugin can be created provided to do this ie tie into the build lifecycle and automatically apply the Exclude Validation on the target folder. 也许我试图看看是否可以创建Maven Eclipse连接器插件来实现这一点,即绑定到构建生命周期并自动在目标文件夹上应用Exclude Validation。

T_T not a good solution. T_T不是一个好的解决方案。 resources is not copied without maven-update 没有maven-update就不会复制资源


maven resources:resources phase marked ignored in Lifecycle Mappings will cause this problem. maven资源:生命周期映射中被忽略的资源阶段将导致此问题。

As Miles pointed out above, eclipse don't copy the resource since it assumes maven will do it for you. 正如迈尔斯上面指出的那样,eclipse不会复制资源,因为它假定maven会为你做这件事。 Then if resources:resources phase which do the job in maven is not executed, you get a file not found exception at runtime. 然后,如果资源:不执行maven中的作业的资源阶段,则在运行时获得文件未找到异常。

to check this open 检查这个开放

project->properties->maven->lifecycle mapping project-> properties-> maven-> lifecycle mapping

and see whether resources:resources is marked ignored or not. 并查看资源:资源是否被标记为被忽略。

to solve it windows->preference->maven->lifecycle mapping-> open workspace lifecycle mappings metadata 解决它windows-> preference-> maven-> lifecycle mapping-> open workspace lifecycle mappings metadata

then change 然后改变

  <action>
    <ignore />
  </action>

to

  <action>
    <execute />
  </action>

for goal resources 目标resources

reload metadata & update maven project 重新加载元数据并更新maven项目

should solve the problem. 应该解决问题。

step 1. delete the project from eclipse step 2. import the project freshly step 3. Go to the folder required to be added as source folder. 步骤1.从eclipse步骤2中删除项目。新导入项目步骤3.转到需要添加为源文件夹的文件夹。

Please refer below screen shot: 请参考下面的屏幕截图: 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM