本文介绍了在Wildfly中使用Jackson注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正努力让Jackson Annotations在我的项目中工作,该项目部署在wildfly中。 我已经尝试过实现MessageBodyWriter 但没有成功。我的项目看起来像这样:我有一个带有ejb模块的耳朵,它带有带注释的Pojos,我有一个带有REST服务的Web模块。这是我当前的配置/依赖项: ejb-module pom.xml: <依赖性> < groupId> com.fasterxml.jackson.core< / groupId> < artifactId> jackson-annotations< / artifactId> < version> 2.2.3< / version> < scope>提供< / scope> < type> jar< / type> < / dependency> rest-module pom.xml: 没有杰克逊依赖。 ear-project pom.xml: <依赖性> < 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-providerservices =import/> < / dependencies> < / deployment> < / jboss-deployment-structure> 但忽略了jackson注释。我错过了什么?或者我做了太多?解决方案 RESTEasy和Jackson依赖项应标记为< scope> ;提供与LT; /范围> 。 此外,如果您只在WAR中使用JAX-RS和Jackson,只需移动 jboss-deployment-structure.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-providerservices =import/> < / dependencies> < / sub-deployment> < / jboss-deployment-structure> I'm struggling to get Jackson Annotations to work in my project which is deployed in wildfly.I already tried implementing a MessageBodyWriter but no success. My project looks like this: I have an ear with an ejb module which holds the annotated Pojos and I have a web module with the REST services. This is my current configuration / dependencies: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>but the jackson annotations are ignored. What am I missing? or did I do too much? 解决方案 The RESTEasy and Jackson dependencies should be marked as <scope>provided</scope>.Also if you're only using JAX-RS and Jackson in your WAR, just move jboss-deployment-structure.xml to your WAR/WEB-INF directory. If you don't want to move it you might need to add a <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> 这篇关于在Wildfly中使用Jackson注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!