gpt4 book ai didi

json - Jersey - Maven - MessageBodyWriter 未找到媒体类型=应用程序/json

转载 作者:行者123 更新时间:2023-12-04 02:04:29 26 4
gpt4 key购买 nike

目前我遇到的问题是 Netbeans 中的所有内容都可以正常工作,但是如果我使用命令“java -jar FILENAME PARAMETERS”启动 jar 文件,则会出现以下错误。

找不到 Media type=application/json 的 MessageBodyWriter,输入
=class java.util.ArrayList, genericType=java.util.List


我需要专家来解决这个问题:/。这很奇怪,因为当我在 Netbeans 中执行 jar 时它可以工作。

pom.xml

http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>at.schneider.development</groupId>
<artifactId>PhotoBoothImageService</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>PhotoBoothImageService</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>[0.4, 0.5)</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>at.schneider.development.photoboothimageservice.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<properties>
<jersey.version>2.26-b02</jersey.version>
<jdk.version>1.8</jdk.version>
</properties>

功能:
@GET
@Path("/getimages")
@Produces(MediaType.APPLICATION_JSON)
public List<Image> getImages() {
availableImages = getImageListFromDirectory(Paths.get(configuration.getProperties().get(BASE_DIR).toString()));
return availableImages;
}

谢谢指教!

此致

最佳答案

我在 comment 中找到了答案来自 Supercop89 :

jersey-media-json-jackson has to be the first dependency.

关于json - Jersey - Maven - MessageBodyWriter 未找到媒体类型=应用程序/json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44552733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com