无法解析 mojo org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade 参数转换器的配置
Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade for parameter transformer
我正在尝试使用 java8 运行时为我的 aws lambda 函数配置 log4j2。 Aws lambda 处理程序确实提供了 context-Lambdalogger,但我想使用标准的 log4j 配置,以便它可以在每个 class 中声明并根据需要记录它,而无需将 context-Lambdalogger 传递给每个方法等等。根据 aws 文档,我尝试使用下面提到的依赖项和插件。但我收到以下错误。任何线索或想法都可以提供帮助。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade (default) on project lcc: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade for parameter transformer: Cannot create instance of interface org.apache.maven.plugins.shade.resource.ResourceTransformer: org.apache.maven.plugins.shade.resource.ResourceTransformer.<init>() -> [Help 1]
< dependency><br/>
< groupId>com.amazonaws< /groupId><br/>
< artifactId>aws-lambda-java-log4j2< /artifactId><br/>
< version>1.0.0< /version><br/>
< /dependency><br/>
< dependency><br/>
< groupId>org.apache.logging.log4j< /groupId><br/>
< artifactId>log4j-core< /artifactId>
< version>2.8.2< /version><br/>
< /dependency><br/>
< dependency><br/>
< groupId>org.apache.logging.log4j< /groupId><br/>
< artifactId>log4j-api< /artifactId><br/>
< version>2.8.2< /version><br/>
< /dependency><br/>
< plugin><br/>
< group Id>org.apache.maven.plugins< /group Id><br/>
< artifactId>maven-shade-plugin< /artifactId><br/>
< version>3.0.0< /version><br/>
< executions><br/>
< execution><br/>
< phase>package< /phase><br/>
< goals><br/>
< goal>shade< /goal><br/>
< /goals><br/>
< configuration><br/>
< transformers><br/>
< transformer><br/>
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer"><br/>
< /transformer><br/>
< /transformers><br/>
< /configuration><br/>
< /execution><br/>
< /executions><br/>
< dependencies><br/>
< dependency><br/>
< group Id>com.github.edwgiz< /group Id><br/>
< artifact Id>maven-shade-plugin.log4j2-cachefile-transformer< /artifactId><br/>
< version>2.8.1< /version><br/>
< /dependency><br/>
< /dependencies><br/>
< /plugin>
我终于明白了!使用转换器时,插件版本 3.0.0 似乎存在一些兼容性问题。我将插件降级到 2.3 版,现在可以正常工作了。
shade 插件现在可以创建 uber jar,并将所有日志组件拉入其中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer">
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.edwgiz</groupId>
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</plugin>
使用插件latest version
时,此问题已解决
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
我正在尝试使用 java8 运行时为我的 aws lambda 函数配置 log4j2。 Aws lambda 处理程序确实提供了 context-Lambdalogger,但我想使用标准的 log4j 配置,以便它可以在每个 class 中声明并根据需要记录它,而无需将 context-Lambdalogger 传递给每个方法等等。根据 aws 文档,我尝试使用下面提到的依赖项和插件。但我收到以下错误。任何线索或想法都可以提供帮助。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade (default) on project lcc: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade for parameter transformer: Cannot create instance of interface org.apache.maven.plugins.shade.resource.ResourceTransformer: org.apache.maven.plugins.shade.resource.ResourceTransformer.<init>() -> [Help 1]
< dependency><br/>
< groupId>com.amazonaws< /groupId><br/>
< artifactId>aws-lambda-java-log4j2< /artifactId><br/>
< version>1.0.0< /version><br/>
< /dependency><br/>
< dependency><br/>
< groupId>org.apache.logging.log4j< /groupId><br/>
< artifactId>log4j-core< /artifactId>
< version>2.8.2< /version><br/>
< /dependency><br/>
< dependency><br/>
< groupId>org.apache.logging.log4j< /groupId><br/>
< artifactId>log4j-api< /artifactId><br/>
< version>2.8.2< /version><br/>
< /dependency><br/>
< plugin><br/>
< group Id>org.apache.maven.plugins< /group Id><br/>
< artifactId>maven-shade-plugin< /artifactId><br/>
< version>3.0.0< /version><br/>
< executions><br/>
< execution><br/>
< phase>package< /phase><br/>
< goals><br/>
< goal>shade< /goal><br/>
< /goals><br/>
< configuration><br/>
< transformers><br/>
< transformer><br/>
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer"><br/>
< /transformer><br/>
< /transformers><br/>
< /configuration><br/>
< /execution><br/>
< /executions><br/>
< dependencies><br/>
< dependency><br/>
< group Id>com.github.edwgiz< /group Id><br/>
< artifact Id>maven-shade-plugin.log4j2-cachefile-transformer< /artifactId><br/>
< version>2.8.1< /version><br/>
< /dependency><br/>
< /dependencies><br/>
< /plugin>
我终于明白了!使用转换器时,插件版本 3.0.0 似乎存在一些兼容性问题。我将插件降级到 2.3 版,现在可以正常工作了。
shade 插件现在可以创建 uber jar,并将所有日志组件拉入其中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer">
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.edwgiz</groupId>
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</plugin>
使用插件latest version
时,此问题已解决 <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>