Java Maven:无法执行目标 org.apache.maven.plugins:maven-resources-plugin:2.7:resources
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26281322/
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
Maven:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources
提问by Avinash Reddy
I am building my project using Maven. My maven version is apache-maven-3.0.4. I am using Eclipse Luna. When I try to build my project I get the following error
我正在使用 Maven 构建我的项目。我的 maven 版本是 apache-maven-3.0.4。我正在使用 Eclipse Luna。当我尝试构建我的项目时,出现以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project OrionCommunity: Mark invalid -> [Help 1].
[错误] 无法在项目 OrionCommunity 上执行目标 org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources):标记无效 -> [帮助 1]。
Following is the stack trace when I run mvn clean install -X
:
以下是我运行 mvn clean install 时的堆栈跟踪-X
:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:53.295s
[INFO] Finished at: Thu Oct 09 20:00:26 IST 2014
[INFO] Final Memory: 9M/25M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project OrionCommunity: Mark invalid -> [Hel
p 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources)
on project OrionCommunity: Mark invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Mark invalid
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:306)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Mark invalid
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:129)
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:300)
... 21 more
Caused by: java.io.IOException: Mark invalid
at java.io.BufferedReader.reset(BufferedReader.java:485)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:416)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:205)
at java.io.Reader.read(Reader.java:123)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:181)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:168)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1856)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1804)
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:114)
... 23 more
My maven repository is under D:/mavenrepo. I have completely deleted all the jars present in the repo and did a clean install. But I still get this error.
我的 maven 仓库在 D:/mavenrepo 下。我已经完全删除了 repo 中存在的所有 jars 并进行了全新安装。但我仍然收到这个错误。
回答by Justin
remove this work for me:
为我删除这项工作:
<filtering>true</filtering>
I guess it is caused by this filtering bug
我想这是由这个过滤错误引起的
回答by arntg
With:
和:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
Was getting the following exception:
收到以下异常:
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Mark invalid
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:306)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 25 more
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Mark invalid
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:129)
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:300)
... 27 more
Caused by: java.io.IOException: Mark invalid
at java.io.BufferedReader.reset(BufferedReader.java:505)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:416)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:205)
at java.io.Reader.read(Reader.java:140)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:181)
at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:168)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1856)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1804)
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:114)
... 29 more
Then it is gone after adding maven-filtering 1.3:
然后添加maven-filtering 1.3后就没了:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
回答by Dan
I had this issue too because I was filtering /src/main/resources and forgot I had added a keystore (*.jks) binary to this directory.
我也有这个问题,因为我在过滤 /src/main/resources 时忘记了我在这个目录中添加了一个密钥库 (*.jks) 二进制文件。
Add a "resource" block with exclusions for binary files and your problem may be resolved.
添加带有二进制文件排除项的“资源”块,您的问题可能会得到解决。
<build>
<finalName>somename</finalName>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>*.jks</exclude>
<exclude>*.png</exclude>
</excludes>
</resource>
</resources>
...
回答by Sourabh Kanojiya
I faced the same problem and did the filtering false like below working for me. You can try the same...
我遇到了同样的问题,并且像下面这样对我进行了过滤错误。你可以试试同样的...
<testResources>
<testResource>
<directory>src/test/java</directory>
<filtering>false</filtering>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
</testResources>
回答by sashok_bg
What worked for me is to add includetag in order to specify exactly what I want to filter.
对我有用的是添加包含标签以准确指定我想要过滤的内容。
It seems the resource plugin has problems going through the whole src/main/resourcefolder, probably due to some specific files inside.
似乎资源插件在遍历整个src/main/resource文件夹时出现问题,可能是由于其中的某些特定文件。
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>application.yml</include>
</includes>
</resource>
</resources>
回答by Santosh Sindham
In my case the targetPath
was not having any value it was blank in the resources --> resource
for the file directory
with files that had issue.
I had to update it to global
as seen in the Code Sample 2
and re-run build to fix the issue.
在我的情况下,targetPath
它没有任何价值,resources --> resource
对于directory
有问题的文件,它在文件中是空白的。我必须将其更新global
为 中所见Code Sample 2
并重新运行构建以解决该问题。
Code Sample 1 (with issue)
代码示例 1(有问题)
<build>
<resources>
<resource>
<directory>src/main/locale</directory>
<filtering>true</filtering>
<targetPath></targetPath>
<includes>
<include>*.xml</include>
<include>*.config</include>
<include>*.properties</include>
</includes>
</resource>
</resources>
Code Sample 2 (fix applied)
代码示例 2(已应用修复)
<build>
<resources>
<resource>
<directory>src/main/locale</directory>
<filtering>true</filtering>
<targetPath>global</targetPath>
<includes>
<include>*.xml</include>
<include>*.config</include>
<include>*.properties</include>
</includes>
</resource>
</resources>
回答by Radouane ROUFID
From official documentation
来自官方文档
Warning: Do not filter files with binary content like images! This will most likely result in corrupt output.
If you have both text files and binary files as resources it is recommended to have two separated folders. One folder src/main/resources (default) for the resources which are not filtered and another folder src/main/resources-filtered for the resources which are filtered.
警告:不要过滤包含图像等二进制内容的文件!这很可能会导致输出损坏。
如果您同时拥有文本文件和二进制文件作为资源,则建议使用两个独立的文件夹。一个文件夹 src/main/resources(默认)用于未过滤的资源,另一个文件夹 src/main/resources-filtered 用于过滤的资源。
<project>
...
<build>
...
<resources>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
...
</resources>
...
</build>
...
</project>
Now you can put those files into src/main/resources which should not filtered and the other files into src/main/resources-filtered.
As already mentioned filtering binary files like images,pdf`s etc.could result in corrupted output.To prevent such problems you can configure file extensions which will not being filtered.
现在,您可以将这些文件放入不应过滤的 src/main/resources 中,而将其他文件放入 src/main/resources-filtered 中。
如前所述,过滤图像、pdf 等二进制文件可能会导致输出损坏。为了防止此类问题,您可以配置不会被过滤的文件扩展名。
Most certainly, You have in your directory files that cannot be filtered. So you have to specify the extensions that has not be filtered.
最肯定的是,您的目录中有无法过滤的文件。因此,您必须指定尚未过滤的扩展名。
回答by Sudabe-Neirizi
in my case, it was a confilict with IntelliJ , I've resolved it by building the project from command line and it worked!
就我而言,这是与 IntelliJ 的冲突,我已经通过从命令行构建项目来解决它并且它有效!
回答by Georgee
I had the same error because of character '@' in my resources/application.properties. All I did was replacing the '@' for its unicode value:
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword\u0040localhost:8082/eureka/
and it worked like charm. I know the '@' is a perfectly valid character in .properties files and the file was in UTF-8 encoding and it makes me question my career till today but it's worth a shot if you delete content of your resource files to see if you can get pass this error.
由于我的 resources/application.properties 中的字符“@”,我遇到了同样的错误。我所做的只是将 '@' 替换为它的 unicode 值:
eureka.client.serviceUrl.defaultZone=http://discUser:discPassword\u0040localhost:8082/eureka/
它的作用就像魅力一样。我知道“@”在 .properties 文件中是一个完全有效的字符,并且该文件采用 UTF-8 编码,这让我怀疑我的职业直到今天,但如果您删除资源文件的内容以查看您是否值得一试可以通过这个错误。