本文介绍了maven-shade-plugin - 在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer 中找不到“资源"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我直接从 apache maven 文档中复制了 maven shade 插件的配置 https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html

I copied configuration of maven shade plugin straight from apache maven documentation https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html

这是我目前的设置:

      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
      <execution>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <manifestEntries>
                <Main-Class>com.my.app.MainClass</Main-Class>
                <X-Compile-Source-JDK>1.8</X-Compile-Source-JDK>
                <X-Compile-Target-JDK>1.8</X-Compile-Target-JDK>
              </manifestEntries>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
                <resource>.properties</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <resource>META-INF/spring.handlers</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <resource>META-INF/spring.schemas</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <resource>META-INF/spring.tooling</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <resource>META-INF/spring.factories</resource>
            </transformer>
          </transformers>
        </configuration>
      </execution>
    </executions>
  </plugin>

我收到以下错误:

[错误] 无法在项目 cpms-batch 上执行目标 org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade (default): 无法解析 mojo org.apache.maven 的配置.插件:maven-shade-plugin:3.1.0:参数资源的阴影:在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer -> [帮助 1] 中找不到资源"org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目 cpms-batch 上执行目标 org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade(默认):无法解析 mojo 组织的配置.apache.maven.plugins:maven-shade-plugin:3.1.0:shade for parameter resource: 在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer 中找不到资源"在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)在 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)在 org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)在 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)在 org.apache.maven.cli.MavenCli.main(MavenCli.java:199)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:498)在 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)引起:org.apache.maven.plugin.PluginConfigurationException: 无法解析 mojo 的配置 org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:662)在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:594)在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)……还有 20 个引起:org.codehaus.plexus.component.configurator.ComponentConfigurationException:在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer 中找不到资源"在 org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:252)在 org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101)在 org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:57)在 org.codehaus.plexus.component.configurator.converters.composite.AbstractCollectionConverter.fromChildren(AbstractCollectionConverter.java:54)在 org.codehaus.plexus.component.configurator.converters.composite.ArrayConverter.fromConfiguration(ArrayConverter.java:52)在 org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty(CompositeBeanHelper.java:273)在 org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:210)在 org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101)在 org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:34)在 org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:632)……还有 23 个[错误]

我已经看到有关该错误的多个问题而没有答案:参数资源的阴影:不能在 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer 类中找到资源"

I've seen multiple questions regarding that error without the answer:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer

找不到资源"在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer

是否有人能够解决它或找到原因?

Was anyone able to resolve it or found the reason?

推荐答案

这篇文章解决了我的问题:https://github.com/spring-projects/spring-boot/issues/384

This post resolved my issue:https://github.com/spring-projects/spring-boot/issues/384

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                            <transformer
                                implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                                <resource>META-INF/spring.factories</resource>
                            </transformer>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.schemas</resource>
                            </transformer>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>${start-class}</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这篇关于maven-shade-plugin - 在类 org.apache.maven.plugins.shade.resource.ManifestResourceTransformer 中找不到“资源"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:27