maven-shade-plugin错误:在“资源”的org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中找不到setter,adder和field [英] maven-shade-plugin error: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'resource'
问题描述
我试图从Spring Boot运行Hello World示例。当我在模块上运行'mvn package'时,我收到以下错误: -
I was trying to run the Hello World example from Spring Boot. When I run 'mvn package' on the module I get the following error:-
[ERROR]无法执行目标org.apache。项目中的maven.plugins:maven-shade-plugin:2.1:shade(默认)spring.boot:无法解析mojo的配置org.apache.maven.plugins:maven-> shade-> plugin:2.1:参数变换器的shade :无法在org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中找到资源 - > [帮助1]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project spring.boot: Unable to parse configuration of mojo org.apache.maven.plugins:maven->shade->plugin:2.1:shade for parameter transformer: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'resource' -> [Help 1]
$ b中的setter,adder或字段$ b
我没有使用任何'资源'属性,但它似乎抱怨这个。知道我在这里做错了什么
I haven't used any 'resource' attribute, but it seems to complain about this. Any idea what I am doing wrong here
这是模块的pom: -
Here is the pom for the module:-
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>spring.boot</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<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.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>hello.SampleController</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
推荐答案
你可以尝试的第一件事就是不要使用shade插件(对于spring-boot插件来说,这是一个较差的解决方案)。 spring-boot插件应该是spring.io中所有示例和指南中的插件。使用初级父母时,它非常简单:
The first thing you could try is to not use the shade plugin (it's an inferior solution in general to the spring-boot plugin). The spring-boot plugin should be the one you find in all samples and guides in spring.io. With the starter-parent in use it's pretty trivial:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
父母已经配置了 ManifestResourceTransformer
,所以我认为这是问题所在。如果您删除< executions />
并设置属性 start-class
,它应该可以正常工作。
The parent has a configuration for ManifestResourceTransformer
already, so I assume that's the problem. If you remove the <executions/>
and set a property start-class
it should work.
如果由于某种原因需要使用阴影并且想要控制配置,那么不要将starter-parent用作父级(也许只是用于< a href =http://docs.spring.io/spring-boot/docs/1.0.2.BUILD-SNAPSHOT/reference/htmlsingle/#using-boot-maven-your-own-parent =noreferrer >依赖管理)。
If you need to use shade for some reason and you want to take control of the configuration, then don't use the starter-parent as a parent (maybe just use it for dependency management).
这篇关于maven-shade-plugin错误:在“资源”的org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中找不到setter,adder和field的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!