【发布时间】:2017-11-18 05:27:58
【问题描述】:
我尝试在 NetBeans 中构建 maven-project。在项目中,我使用 jersey-media-json-jackson。我的依赖项看起来像这样
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.23.1</version>
</dependency>
如果我在 IDE 中运行项目,则一切正常。但是,如果我使用依赖项构建项目并运行生成的 jar 文件,则会出现以下错误
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.ats.orion.client.model.req.UpdateContextRequest, genericType=class com.ats.orion.client.model.req.UpdateContextRequest.
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class com.ats.orion.client.model.req.UpdateContextRequest, genericType=class com.ats.orion.client.model.req.UpdateContextRequest.
当我注释 jersey-media-json-jackson 依赖项时,IDE 中出现相同的异常。
我在 pom.xml 中的构建块
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ats.test.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
如何解决我的问题?
【问题讨论】:
-
我希望你运行的是
jar-with-dependencies而不是默认生成的jar。