我直接从apache maven文档https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
复制了maven shade插件的配置这是我目前的设置:
<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(默认):无法解析mojo org.apache.maven的配置。插件:maven-shade-plugin:3.1.0:参数资源的阴影:无法找到&#39;资源&#39;在类org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中 - &gt; [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目cpms-batch上执行目标org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade(默认):无法解析mojo org的配置。 apache.maven.plugins:maven-shade-plugin:3.1.0:参数资源的阴影:无法找到&#39;资源&#39;在类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) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at 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:无法找到&#39; resource&# 39;在类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:无法找到&#39;资源&#39;在类org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中 在org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:252) at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101) at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:57) at org.codehaus.plexus.component.configurator.converters.composite.AbstractCollectionConverter.fromChildren(AbstractCollectionConverter.java:54) at 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) at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101) at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:34) 在org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:632) ......还有23个 [错误]
我在没有答案的情况下看到了有关该错误的多个问题: shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer
Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer
有人能够解决它或找到原因吗?
答案 0 :(得分:9)
这篇文章解决了我的问题: 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>
答案 1 :(得分:1)
Spring Boot有自己的maven-shade-plugin配置。将此属性添加到您的pom.xml:
<properties>
<start-class>com.ing.tpa.core.test.integration.apns.mock.MockAPNSServer</start-class>
</properties>