<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>Maven_HelloWroldgroupId>
<artifactId>com.juvnxu.mvnbookartifactId>
<version>0.0.1-SNAPSHOTversion>
<name>Maven_Hellowroldname>
<dependencies>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>4.6version>
<scope>testscope>
dependency>
dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<configuration>
<source>1.8source>
<target>1.8target>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-shade-pluginartifactId>
<version>1.2.1version>
<executions>
<execution>
<phase>packagephase>
<goals>
<goal>shadegoal>
goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourcesTransformer">
<mainClass>com.juvnxu.mvnbook.Maven_Hellowrold.HelloWrold_zhumainClass>
transformer>
transformers>
configuration>
execution>
executions>
plugin>
plugins>
build>
project>
PS D:\eclipse项目\Maven_Hellowrold> mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven_Hellowrold 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.juvnxu.mvnbook ---
[INFO] Deleting D:\eclipse项目\Maven_Hellowrold\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.juvnxu.mvnbook ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ com.juvnxu.mvnbook ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse项目\Maven_Hellowrold\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ com.juvnxu.mvnbook ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ com.juvnxu.mvnbook ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse项目\Maven_Hellowrold\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ com.juvnxu.mvnbook ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ com.juvnxu.mvnbook ---
[INFO] Building jar: D:\eclipse项目\Maven_Hellowrold\target\com.juvnxu.mvnbook-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:1.2.1:shade (default) @ com.juvnxu.mvnbook ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.180 s
[INFO] Finished at: 2023-02-24T17:56:22+08:00
[INFO] Final Memory: 17M/179M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.2.1:shade (default) on project com.juvnxu.mvnbook: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:1.2.1:shade for parameter transformers: Cannot load implementation hint 'org.apache.maven.plugins.shade.resource.ManifestResourcesTransformer' -> [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/PluginConfigurationException
该回答引用GPTᴼᴾᴱᴺᴬᴵ
根据报错信息,插件无法解析配置,可能是插件版本不兼容或配置错误导致的。建议更新插件版本并修改配置文件。
可以尝试以下操作:
1.将maven-shade-plugin的版本更新到较新版本,例如3.2.2
2.修改transformer实现类的写法为全类名,如下所示:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourcesTransformer">
3.将插件和插件配置放在标签内,如下所示:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourcesTransformer">
<mainClass>com.juvnxu.mvnbook.Maven_Hellowrold.HelloWrold_zhu</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
4.最后再运行 mvn clean package 命令进行打包。