部署目标期间 maven-resources-plugin 中的 IllegalArgumentException

IllegalArgumentException in maven-resources-plugin during deploy goal

我正在尝试使用以下命令使用 Maven 构建我的 spring-boot 应用程序。

mvn -X -Dmaven.test.skip=true deploy

在此步骤中,maven-resources-plugin 尝试将我的 application.yaml 文件复制到我的 target\classes 文件夹。这失败了 IllegalArgumentException.

堆栈跟踪的相关部分。

[INFO] Copying 1 resource
[DEBUG] Copying file application.yaml
[DEBUG] file application.yaml has a filtered file extension
[DEBUG] Using 'UTF-8' encoding to copy filtered resource 'application.yaml'.
[DEBUG] filtering XXX\src\main\resources\application.yaml to XXX\target\classes\application.yaml
Caused by: java.lang.IllegalArgumentException
    at java.nio.Buffer.position (Buffer.java:244)
    at org.apache.maven.shared.utils.io.FileUtils.copyFile (FileUtils.java:1946)
    at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile (DefaultMavenFileFilter.java:98)
    at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources (DefaultMavenResourcesFiltering.java:262)
    at org.apache.maven.plugins.resources.ResourcesMojo.execute (ResourcesMojo.java:356)

关于失败原因的任何想法? 如何确保我的文件被复制?

如果我从资源文件夹中删除我的 yaml 文件,我的构建就会成功!

更多堆栈跟踪

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project sonar-notification-app: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
Caused by: java.lang.IllegalArgumentException
    at java.nio.Buffer.position (Buffer.java:244)
    at org.apache.maven.shared.utils.io.FileUtils.copyFile (FileUtils.java:1946)
    at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile (DefaultMavenFileFilter.java:98)
    at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources (DefaultMavenResourcesFiltering.java:262)
    at org.apache.maven.plugins.resources.ResourcesMojo.execute (ResourcesMojo.java:356)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)```

终于找到问题所在了。当我们打包应用程序时,我们使用 maven-dependency-plugin 将两个工件 类 复制到一个 类 文件夹中。这两个工件都有自己的 application.yaml 文件。这导致了这个错误。希望这对遇到类似问题的任何人有所帮助。