SpringBoot 2.4.0 org.apache.maven.plugin.MojoExecutionException: Input length = 1

SpringBoot 2.4.0 编译打包时出现了org.apache.maven.plugin.MojoExecutionException: Input length = 1:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project demo: Input length = 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project zskeeper_server: Input length = 1
    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:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
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)

异常的原因:
在于SpringBoot2.4.0升级了maven-resources-plugin到3.2.0版本,且工程中的application.properties不是UTF-8编码,在编译时出现异常。但实际上maven-resources-plugin 3.1.0版本没有这个问题。有人已经在maven官网提出了这个issue。
一开始,笔者以为是SpringBoot打包插件的异常,所以也给SpringBoot提出了这个问题。请看SpringBoot issue

这个异常有两个解决方案:
方案1
修改application.properties文件的编码方式,选用UTF-8编码方式,idea中设置如下
SpringBoot 2.4.0 org.apache.maven.plugin.MojoExecutionException: Input length = 1_第1张图片
方案2(不推荐)
降级maven-resources-plugin的版本到3.1.0

<plugin>
	<groupId>org.apache.maven.pluginsgroupId>
	<artifactId>maven-resources-pluginartifactId>
	<version>3.1.0version>
plugin>

你可能感兴趣的:(SpringBoot 2.4.0 org.apache.maven.plugin.MojoExecutionException: Input length = 1)