我正在努力让杰克逊注释在我的项目中工作,该项目部署在野蝇中。
我已经尝试过实现MessageBodyWriter,但没有成功。我的项目如下所示:我有一个带有ejb模块的耳朵,该模块包含带注释的Pojos,我有一个带有REST服务的Web模块。这是我当前的配置/依赖项:
ejb-module pom. xml:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.3</version>
<scope>provided</scope>
<type>jar</type>
</dependency>
rest模块pom. xml:
no jackson dependencies.
ear-project pom. xml:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.0.6.Final</version>
</dependency>
EAR-项目 /META-INF/jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
</exclusions>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
但是杰克逊的注释被忽略了。我错过了什么?还是我做得太多了?
RESTEasy和Jackson依赖项应标记为
此外,如果您在WAR中只使用JAX-RS和Jackson,只需将jbost-部署结构. xml
移动到您的WAR/WEB-INF
目录。如果您不想移动它,您可能需要添加
<jboss-deployment-structure>
<sub-deployment name="rest-module.war">
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
</exclusions>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>