Maven shade + resteasy Could find writer for content-type

帅比萌擦擦* 提交于 2019-12-31 04:01:07

问题


I have a project that works fine with maven managed dependencies. But I have a requirement for giving my jar files as one.

For this I use maven-shade plugin (http://maven.apache.org/plugins/maven-shade-plugin/). All class files are exported correctly but when I try to run my application I get an error as:

Could find writer for content-type multipart/form-data type: org.jboss.reasteasy.plugins.provider.multipart.MultipartFormDataOutput

Any help would be great, thanks.

Note: I had a similar problem with spring whose main cause is configuration files. Many jar files contained a configuraiton file that has same name. All configuration files tries to override the others. After merging that file with maven-shade configuration problem was solved.


回答1:


You maybe missing one of the Shade transformers listed below. I was seeing the same error as yours when running 'java -jar' on my Shade-built jar file. Make sure you have a org.apache.maven.plugins.shade.resource.ServicesResourceTransformer entry. JAR files providing implementations of some interfaces often ship with a META-INF/services/ directory that maps interfaces to their implementation classes for lookup by the service locator. To merge multiple implementations of the same interface into one service entry, the ServicesResourceTransformer can be used. I believe this was the case with RestEasy running under Shade.

<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">
                                <mainClass>path.to.your.App</mainClass>
                            </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.ServicesResourceTransformer" />
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


来源:https://stackoverflow.com/questions/20147760/maven-shade-resteasy-could-find-writer-for-content-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!