简体   繁体   English

Maven 全新安装:无法执行目标 org.apache.maven.plugins:maven-resources-plugin:3.20。

[英]Maven clean install: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources

I don´t know what´s the problem.我不知道是什么问题。 Trying to install maven for a college project.尝试为大学项目安装 maven。 I already installed maven as instructed here .我已经按照此处的说明安装了 maven 。 Picture Environmental Variables , maven version in cmd And I also tried to delete the.m2 file.图片 环境变量, maven 版本在 cmd并且我也尝试删除.m2文件。 When I try to install maven over the plugin in InteliJ, I get the message: "process terminated" with no extra info.当我尝试通过 InteliJ 中的插件安装 maven 时,我收到消息:“进程终止”,没有额外信息。 Then I tried to install over the terminal with mvn clean install and i got this.然后我尝试使用 mvn clean install 在终端上安装,我得到了这个。

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.college:sprinttool:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.boot:spring-boot-starter-data-jpa:jar -> duplicate declaration of version (?) @ line 50, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.boot:spring-boot-starter-test:jar -> duplicate declaration of version (?) @ line 55, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -------------------< com.college:sprinttool >--------------------
[INFO] Building sprinttool 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ sprinttool ---
[INFO] Deleting E:\Code Practices\sprinttool\sprinttool\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ sprinttool ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.740 s
[INFO] Finished at: 2021-01-26T22:56:19+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project sprinttool: Input length = 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Then I ran "mvn clean install -X" for more Information and it gives out this in addition.然后我运行“mvn clean install -X”以获取更多信息,它还给出了这个。

    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)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Input length = 1
    at org.apache.maven.plugins.resources.ResourcesMojo.execute (ResourcesMojo.java:362)
    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)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Input length = 1
    at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile (DefaultMavenFileFilter.java:113)
    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)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.charset.MalformedInputException: Input length = 1
    at java.nio.charset.CoderResult.throwException (CoderResult.java:274)
    at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:352)
    at sun.nio.cs.StreamDecoder.read (StreamDecoder.java:188)
    at java.io.InputStreamReader.read (InputStreamReader.java:181)
    at java.io.BufferedReader.read1 (BufferedReader.java:210)
    at java.io.BufferedReader.read (BufferedReader.java:287)
    at java.io.BufferedReader.fill (BufferedReader.java:161)
    at java.io.BufferedReader.read (BufferedReader.java:182)
    at org.apache.maven.shared.filtering.BoundedReader.read (BoundedReader.java:85)
    at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:235)
    at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:197)
    at java.io.Reader.read (Reader.java:229)
    at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:199)
    at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:181)
    at org.apache.maven.shared.utils.io.FileUtils.copyFile (FileUtils.java:1908)
    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)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I honestly have no clue what it is telling me.老实说,我不知道它在告诉我什么。 Is it because there is something wrong with my pom.xml?是不是因为我的 pom.xml 有问题? Pls help me.请帮助我。 Thank you in advance.先感谢您。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.college</groupId>
    <artifactId>sprinttool</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>sprintplanningtool</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>15</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.3</version>
        </dependency-->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
        </dependency>

        <!--dependency>
            <groupId>javax.el</groupId>
            <artifactId>javax.el-api</artifactId>
            <version>3.0.0</version>
        </dependency-->

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-bom</artifactId>
            <version>5.3.3.RELEASE</version>
        </dependency>
        <!--dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator-annotation-processor</artifactId>
            <version>6.0.2.Final</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>javax.el</artifactId>
            <version>2.2.6</version>
        </dependency-->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Edit: I used the spring boot intitializer to create the project.编辑:我使用 spring 启动初始化程序来创建项目。

It might be a new bug coming with some latest release of Spring-boot (and then: Spring ).这可能是一些最新版本的Spring-boot (然后是: Spring )的新错误。

I had it.我有它。 The workaround is to put in your pom.xml this corrected dependency:解决方法是在您的pom.xml中添加此更正的依赖项:

<!-- Pour contourner un bug à la génération par Spring-boot 2.4.x : 
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project application-etude: Input length = 1 -->               
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.1.0</version>
</plugin>               

The root cause of the exception is that some resources contain resources which should not filtered (aka binary).异常的根本原因是某些资源包含不应过滤的资源(也称为二进制)。 The correct solution is to define an exclude for file extensions which should not filtered like the following :正确的解决方案是为不应过滤的文件扩展名定义一个排除项, 如下所示

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <nonFilteredFileExtensions>
            <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
            <nonFilteredFileExtension>swf</nonFilteredFileExtension>
          </nonFilteredFileExtensions>
        </configuration>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

I had the same problem and fixed it by adding in the pom.xml:我遇到了同样的问题并通过添加 pom.xml 来修复它:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Here is the comment that help me solved the problem: https://github.com/spring-projects/spring-boot/issues/24346#issuecomment-740345146这是帮助我解决问题的评论: https://github.com/spring-projects/spring-boot/issues/24346#issuecomment-740345146

In my case, the error happened because I had properties files encoded with ANSI, while maven was trying to use UTF-8.就我而言,发生错误是因为我有使用 ANSI 编码的属性文件,而 maven 试图使用 UTF-8。 I fixed it by converting my properties files to UTF-8, and then running mvn clean compile .我通过将我的属性文件转换为 UTF-8,然后运行mvn clean compile来修复它。

In my case, the error was due to accents on "application.properties"在我的情况下,错误是由于“application.properties”的重音

It would certainly be far easier to fix such errors if the tool simply gave a message saying that a certain file contains invalid characters...如果该工具只是给出一条消息说某个文件包含无效字符,那么修复此类错误肯定会容易得多......

For the record, the relevant log part, after running mvn clean package -e -X , was this one:作为记录,在运行mvn clean package -e -X之后,相关的日志部分是这个:

[DEBUG] Using 'UTF-8' encoding to copy filtered resource 'application.properties'.
[DEBUG] filtering D:\Java\PreVendaAPI\src\main\resources\application.properties to D:\Java\PreVendaAPI\target\classes\application.properties
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

I faced the same issue, and fixed it using the below changes in my pom.xml build plugin.我遇到了同样的问题,并使用我的 pom.xml 构建插件中的以下更改修复了它。

<project>
...
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
        </plugins>
    </build>
</project>

You need exclude binary resourses.您需要排除二进制资源。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
        <propertiesEncoding>UTF-8</propertiesEncoding>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>xls</nonFilteredFileExtension>
            <nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

I had the same error.我有同样的错误。 After removing german umlauts ('ü') from comments in my propertie files, they should be filtered, the problem is gone!从我的属性文件中的注释中删除德语变音符号('ü')后,它们应该被过滤,问题就消失了!

Some of your resources contains a character not in the ISO-8859-1 codepage, and this can cause disturbance here:您的某些资源包含不在 ISO-8859-1 代码页中的字符,这可能会在此处引起干扰:

   at java.io.Reader.read (Reader.java:229)
   at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:199)

A typical error might be an accentuated character in a.properties file.一个典型的错误可能是 .properties 文件中的重音字符。

The problem is with the maven-resources-plugin.问题出在 maven-resources-plugin 上。 Newer versions of this plugin are less lenient than the older versions.这个插件的新版本没有旧版本那么宽松。 Unfortunately, the error message that is displayed when the Maven build fails (Input length = 1) is only helpful if you recognize it from previous experience with character set problems in Java.不幸的是,当 Maven 构建失败(输入长度 = 1)时显示的错误消息只有在您从以前的 Java 中的字符集问题经验中识别出来时才有用。

You can add some options to the Maven build command so it will display DEBUG level output and a full stacktrace on build failures.您可以在 Maven 构建命令中添加一些选项,这样它将在构建失败时显示 DEBUG 级别 output 和完整的堆栈跟踪。 Try this as your first step in diagnosing the root cause:尝试将此作为诊断根本原因的第一步:

mvn -e -X clean test

It will output a LOT of info to the console during the build with these options turned on.在打开这些选项的构建过程中,它将 output 向控制台发送大量信息。 Just wait until the failure happens and check the end of the console output.等到故障发生并检查控制台output的结束。 You should see a full stacktrace at the end that will make more sense.您应该在最后看到一个完整的堆栈跟踪,这将更有意义。 Just before the stacktrace, you should also see the name of the file in your project that caused the error.就在堆栈跟踪之前,您还应该看到项目中导致错误的文件的名称。 For me, I saw output like this:对我来说,我看到 output 是这样的:

directory C:\GITROOT\conndev\repos\conn-lamp-server\src\test\resources
excludes []
includes []
[DEBUG] ignoreDelta true
[INFO] Copying 3 resources
[DEBUG] Copying file application-inttest.properties
[DEBUG] file application-inttest.properties has a filtered file extension
[DEBUG] Using 'UTF-8' encoding to copy filtered resource 'application-inttest.properties'.
[DEBUG] filtering C:\GITROOT\conndev\repos\conn-lamp-server\src\test\resources\application-inttest.properties to C:\GITROOT\conndev\repos\conn-lamp-server\target\test-classes\application-inttest.properties
[DEBUG] Copying file DummyExcelFile.xls
[DEBUG] file DummyExcelFile.xls has a filtered file extension
[DEBUG] Using 'UTF-8' encoding to copy filtered resource 'DummyExcelFile.xls'.
[DEBUG] filtering C:\GITROOT\conndev\repos\conn-lamp-server\src\test\resources\DummyExcelFile.xls to C:\GITROOT\conndev\repos\conn-lamp-server\target\test-classes\DummyExcelFile.xls
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  37.927 s
[INFO] Finished at: 2022-04-26T10:11:09-03:00
[INFO] ------------------------------------------------------------------------

Now I know that a file in my test resources directory was the problem:现在我知道我的测试资源目录中的一个文件是问题所在:

src\test\resources\DummyExcelFile.xls

Older versions of the resources plugin must have been quietly suppressing the problem.旧版本的资源插件一定是悄悄地压制了这个问题。 I won't include the full stacktrace here, but this is the important line from the stacktrace:我不会在这里包含完整的堆栈跟踪,但这是堆栈跟踪中的重要行:

Caused by: java.nio.charset.MalformedInputException: Input length = 1

I've seen this before.我以前见过这个。 It happens when a text file cannot be read by a Java 'reader' class because the file contains one or more characters that are invalid for the character set used by the reader.当 Java 'reader' class 无法读取文本文件时会发生这种情况,因为该文件包含一个或多个对于阅读器使用的字符集无效的字符。 In my case, it was trying to read a binary file as text, so that was never going to work.就我而言,它试图将二进制文件作为文本读取,所以这永远不会奏效。 The same problem could happen if you have a text file that contains unusual characters (such as those from European languages with accents) and those characters are not valid for the character set you are using (such as UTF-8).如果您的文本文件包含异常字符(例如带有重音符号的欧洲语言)并且这些字符对于您使用的字符集(例如 UTF-8)无效,则可能会发生同样的问题。 All these problems can be solved with some POM configuration.所有这些问题都可以通过一些 POM 配置来解决。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <propertiesEncoding>UTF-8</propertiesEncoding>
                <nonFilteredFileExtensions>
                    <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                    <nonFilteredFileExtension>zip</nonFilteredFileExtension>
                </nonFilteredFileExtensions>
            </configuration>
        </plugin>

If you are using a different character set from UTF-8, just substitute yours in the XML snippet above.如果您使用与 UTF-8 不同的字符集,只需在上面的 XML 片段中替换您的字符集。 Do the same for any file extensions that you want the maven-resource-plugin to ignore when it does filtering.对您希望 maven-resource-plugin 在过滤时忽略的任何文件扩展名执行相同操作。

Note that I have intentionally omitted the <version> for the maven-resources-plugin block above.请注意,我故意省略了上面 maven-resources-plugin 块的<version> This is because I am using the spring-boot-starter-parent in my POM and the version of many dependencies is inherited from the parent.这是因为我在我的 POM 中使用spring-boot-starter-parent并且许多依赖项的版本是从父级继承的。 If you do not use a parent, then you will have to explicitly set the version you want to use.如果您不使用父版本,则必须明确设置要使用的版本。

This message came up today, here is what I did to resolve it:今天出现了这条消息,这是我为解决它所做的:

I used mvn to analyze the resources like this:我使用 mvn 来分析这样的资源:

mvn -X process-test-resources

This way mvn returned the name of the file wich was causing the error:这样 mvn 返回导致错误的文件的名称:

[DEBUG] filtering .../messages.properties
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  x
[INFO] Finished at: y
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on foo: Input length = 1 -> 

Turned out messages.properties contained special chars which had not been escaped properly.结果是messages.properties 包含未正确转义的特殊字符。 So I escaped them in the i18n-file and after that I was able to build again.所以我在 i18n 文件中转义了它们,之后我能够再次构建。

I Belive that error heppens because have some problems of compatibility R: The possible solution is to insert this plugin in pom.xml我相信这个错误是因为有一些兼容性问题 R:可能的解决方案是在pom.xml中插入这个插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.1.0</version>
</plugin>

For me stopping the server helped对我来说,停止服务器有帮助

(On Windows 10) npx kill-port your_port

By default, maven-resources-plugin uses project.build.sourceEncoding when filtering resources (which defaults to UTF-8 ).默认情况下,maven-resources-plugin 在过滤资源时使用project.build.sourceEncoding (默认为UTF-8 )。

The java standard for .properties files requires ISO-8859-1 encoding. .properties文件的 java 标准需要ISO-8859-1编码。

To resolve this, you can explicitely configure how .properties Files should be filtered:要解决此问题,您可以明确配置应如何过滤.properties文件:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>3.2.0</version>
  <configuration>
    <propertiesEncoding>ISO-8859-1</propertiesEncoding>
  </configuration>
</plugin>

This is also described in the official documentation of the plugin: https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html这在插件的官方文档中也有描述: https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.ZFC35FDC70D5FC69D23EZ8C

Estava com um problema semelhante em um projeto spring, a resolução foi essa, mudei a versão do plugin maven, que no meu arquivo pom.xml não tinha, adicionei e testei a versão 3.1.0 e deu certo. Estava com um problema semelhante em um projeto spring, a resolução foi essa, mudei a versão do plugin maven, que no meu arquivo pom.xml não tinha, adicionei e testei a versão 3.1.0 e deu certo.

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>

I think you are defining application.property and application.yml at the same time.我认为您同时定义了application.propertyapplication.yml If you want to use both of them, please try plug the maven-resources-plugin如果你想同时使用它们,请尝试插入maven-resources-plugin

Using this dependency solved this problem of mine使用这个依赖解决了我的这个问题

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.2.0</version>
</dependency>

I had the same error when writing non utf-8 characters in a comment in application.properties file.在 application.properties 文件的注释中写入非 utf-8 字符时,我遇到了同样的错误。 I deleted those characters and it's working !我删除了这些字符,它正在工作!

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Use this in application.properties file that will definetly work.在绝对有效的 application.properties 文件中使用它。

暂无
暂无

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

相关问题 Maven:无法执行目标 org.apache.maven.plugins:maven-resources-plugin:2.7:resources - Maven:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources 未能执行目标 org.apache.maven.plugins:maven-resources-plugin:2.5:resources - Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources 如何解决无法执行目标org.apache.maven.plugins:maven-resources-plugin - How to resolve Failed to execute goal org.apache.maven.plugins:maven-resources-plugin 无法执行目标org.apache.maven.plugins:maven-resources-plugin:2.7 - failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7 MAVEN 错误:“无法执行目标 org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean” - MAVEN ERROR : "Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean " org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources 失败并出现 MalformedInputException - org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources fails with MalformedInputException 目标org.apache.maven.plugins的执行默认资源:maven-resources-plugin:2.6:resources失败 - Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed Maven - 未能执行目标 org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean - Maven - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean 无法读取org.apache.maven.plugins:maven-resources-plugin:jar:3.0.5的工件描述符 - Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:3.0.5 无法执行目标org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM