Encountering errors in Maven builds can be frustrating, especially cryptic ones like the error below:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project : Input length = 1

This guide walks you through understanding and resolving this error effectively.

Understanding the Error

The error originates from the Maven Resources Plugin (maven-resources-plugin) which processes resource files during the build. The key part of the message, Input length = 1, hints at an encoding issue when Maven tries to process a resource file, such as application.properties or any file under the src/main/resources directory.

This usually occurs when:

  1. There’s an invalid character in one of the resource files.
  2. The file encoding specified in Maven or Java doesn’t match the encoding used in the resource files.
  3. Corrupted or improperly saved files are included in the resources folder.

Steps to Resolve the Error

Step 1: Check for Invalid Characters

  1. Inspect all files in the src/main/resources directory:
    • Open files like application.properties, application.yml, or any custom resource files.
    • Look for non-ASCII characters or characters saved in an unexpected encoding format.
  2. Use tools like a text editor with encoding detection (e.g., Notepad++, Visual Studio Code, or IntelliJ IDEA).Tip: In IntelliJ IDEA, you can check a file’s encoding by opening it and looking at the bottom-right corner.

Step 2: Fix File Encoding

Ensure all files in the resources directory are saved with the correct encoding. UTF-8 is the recommended standard.

Steps:

  • Open the problematic file(s) in an editor like Notepad++.
  • Change the encoding:
    • In Notepad++, go to Encoding > Convert to UTF-8 (without BOM).
    • Save the file.

Step 3: Configure Maven to Use UTF-8

Specify UTF-8 as the encoding for resource processing in the Maven pom.xml file.

Add the following to the <plugins> section of pom.xml:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

This ensures Maven processes resource files using UTF-8.

Step 4: Clean and Rebuild the Project

After making the changes:

  1. Run the following Maven commands:bashCopier le code
mvn clean install

2.Ensure no additional errors appear during the build.

Conclusion

The [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources error is commonly caused by encoding mismatches or invalid characters in resource files. By following the steps above, you should be able to resolve the issue and ensure smooth builds with Maven.

You can see also :

https://www.trywithgeek.com/junit-error-failed-to-execute-goal-org-apache-maven-pluginsmaven-compiler-plugin3-10-1testcompile-default-testcompile-on-project/

https://stackoverflow.com/questions/65910112/maven-clean-install-failed-to-execute-goal-org-apache-maven-pluginsmaven-resou

Happy coding!

Aller au contenu principal