我正努力让Jackson Annotations在我的项目中工作,该项目部署在wildfly中。
我已经尝试implementing a 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-module 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-project /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>
但杰克逊注释被忽略了。我错过了什么?还是我做得太多了?
答案 0 :(得分:2)
RESTEasy和Jackson依赖项应标记为<scope>provided</scope>
。
此外,如果您只在WAR中使用JAX-RS和Jackson,只需将jboss-deployment-structure.xml
移至WAR/WEB-INF
目录即可。如果您不想移动它,则可能需要添加<sub-deployment/>
。
<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>