我想在JBOSS中使用我的自定义Jackson版本。为此,我想排除本地jboss jackson库,并将我的版本添加为gradle依赖项。 我还在项目中使用resteasy,并且不想排除jax-rs模块。 可能吗? 尝试配置
jboss-deployment-structure.xml
但这没有帮助:
org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 5 second(s)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:268)
at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands.convertLettuceAccessException(LettuceKeyCommands.java:817)
at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands.keys(LettuceKeyCommands.java:229)
at org.springframework.data.redis.connection.DefaultedRedisConnection.keys(DefaultedRedisConnection.java:97)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.keys(DefaultStringRedisConnection.java:630)
at org.springframework.data.redis.core.RedisTemplate.lambda$keys$13(RedisTemplate.java:883)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
at org.springframework.data.redis.core.RedisTemplate.keys(RedisTemplate.java:883)
objectMapper.getClass()。getPackage()。getImplementationVersion()
总是恐惧
2.8.9.redhat-1
答案 0 :(得分:1)
问题在于,杰克逊库是org.jboss.resteasy.resteasy-jackson2-provider
模块的依赖项。该模块是使用JAX-RS批注的EAR的任何WAR子部署的自动依赖项(请参阅Redhat 7.2开发指南的表3.1。隐式模块依赖项)。
您需要使用JAX-RS在WAR的子部署级别上排除resteasy-jackson2-provider
模块,然后重新定义它以排除所有杰克逊依赖项。您可以在类似情况下看到此方法(自动依赖项包含的模块)https://developer.jboss.org/thread/175075
我已经在JBoss 7.2.6上进行了测试
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<sub-deployment name="myrestmodule.war">
<dependencies>
<module name="deployment.org.jboss.resteasy.resteasy-jackson2-provider" />
</dependencies>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
</exclusions>
</sub-deployment>
<module name="deployment.org.jboss.resteasy.resteasy-jackson2-provider">
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" export="true">
<imports>
<exclude path="com/fasterxml/jackson/**" />
</imports>
</module>
</dependencies>
</module>
</jboss-deployment-structure>
必需的jackson库必须包含在myrestmodule.war WEB-INF / lib文件夹中。
已更新
如果杰克逊不仅在EAR的其他库中使用,而且不仅在使用JAX-RS的WAR中使用,则此方法不起作用。例如,如果在WAR上使用EAR的库目录中JAR中的bean,杰克逊将无法识别其中的注释。
要使此部署正常进行,必须在EAR部署级别上排除“ org.jboss.resteasy.resteasy-jackson2-provider”模块,并且将jackson库包含在以下目录的库目录中EAR,而不是WAR的WEB-INF / lib。
这将是EAR的META-INF目录上的更新的jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="deployment.org.jboss.resteasy.resteasy-jackson2-provider" />
</dependencies>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
</exclusions>
</deployment>
<sub-deployment name="myrestmodule.war">
<dependencies>
<module name="deployment.org.jboss.resteasy.resteasy-jackson2-provider" />
</dependencies>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
</exclusions>
</sub-deployment>
<module name="deployment.org.jboss.resteasy.resteasy-jackson2-provider">
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" export="true">
<imports>
<exclude path="com/fasterxml/jackson/**" />
</imports>
</module>
</dependencies>
</module>
</jboss-deployment-structure>