猿问

如何在Wildfly中配置Jackson?

我有一个使用以下方法的会话Bean:


@POST

@Consumes("application/x-www-form-urlencoded")

@Path("/calculate")

@Produces("application/json")

public CalculationResult calculate(@FormParam("childProfile") String childProfile,

        @FormParam("parentProfile") String parentProfile) {

...

}

返回的CalculationResult无法映射到JSON,并且发生以下异常:


Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.test.UniqueName and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)...

如何SerializationFeature在Wildfly中配置Jackson及其及其?


蛊毒传说
浏览 461回答 2
2回答

慕斯王

野蝇9pom.xml<dependency>&nbsp; &nbsp; <groupId>org.jboss.resteasy</groupId>&nbsp; &nbsp; <artifactId>resteasy-jackson2-provider</artifactId>&nbsp; &nbsp; <version>3.0.8.Final</version>&nbsp; &nbsp; <scope>provided</scope></dependency>Java类@com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)public class SomePojo implements Serializable {}
随时随地看视频慕课网APP

相关分类

Java
我要回答