如何使用 Wildfly Swarm 解决 class io.swagger.jaxrs.listing.SwaggerSerializers 的 WELD-001318?
How to resolve WELD-001318 with Wildfly Swarm for class io.swagger.jaxrs.listing.SwaggerSerializers?
我在我的 pom.xml 中添加了 Wildfly Swarm 2017.12.1。我没有手动添加分数,因为所有分数都是自动发现的:
2018-01-03 14:37:34,976 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Logging - STABLE org.wildfly.swarm:logging:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS with JAXB - STABLE org.wildfly.swarm:jaxrs-jaxb:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI Configuration - STABLE org.wildfly.swarm:cdi-config:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI - STABLE org.wildfly.swarm:cdi:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Hibernate Validator - STABLE org.wildfly.swarm:hibernate-validator:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS with Validation - STABLE org.wildfly.swarm:jaxrs-validator:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JCA - STABLE org.wildfly.swarm:jca:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Datasources - STABLE org.wildfly.swarm:datasources:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Bean Validation - STABLE org.wildfly.swarm:bean-validation:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Elytron - STABLE org.wildfly.swarm:elytron:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS - STABLE org.wildfly.swarm:jaxrs:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JPA - STABLE org.wildfly.swarm:jpa:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Transactions - STABLE org.wildfly.swarm:transactions:2017.12.1
2018-01-03 14:37:34,984 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Undertow - STABLE org.wildfly.swarm:undertow:2017.12.1
2018-01-03 14:37:34,984 WARN [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Swagger - UNSTABLE org.wildfly.swarm:swagger:2017.12.1
招摇分数不稳定。我不确定为什么,但无论如何。它被添加了,后来我得到了一些错误。我收到的错误消息是这样的:
2018-01-03 14:37:46,545 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 11) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: RESTEASY003945: Unable to instantiate MessageBodyWriter
.... long stacktrace ...
Caused by: java.lang.RuntimeException: RESTEASY003945: Unable to instantiate MessageBodyWriter
... long stacktrace ...
Caused by: org.jboss.weld.exceptions.AmbiguousResolutionException: WELD-001318: Cannot resolve an ambiguous dependency between:
- Managed Bean [class io.swagger.jaxrs.listing.SwaggerSerializers] with qualifiers [@Any @Default],
- Managed Bean [class io.swagger.jaxrs.listing.SwaggerSerializers] with qualifiers [@Any @Default]
... stacktrace...
如您所见,它在类路径中找到了两次 SwaggerSerializers,所以我猜这是 Swarm 安装 swagger fraction 的问题。
也许如果我手动添加所有依赖项,那么它可能会奏效。但我认为这不是一个好的解决方案。
如 https://issues.jboss.org/browse/SWARM-271 中所述,这是一个错误。
有什么办法可以解决这个问题吗?
我找到了解决方案。我只需要在项目的 pom 中添加 <scope>provided</scope>
到 swagger 的依赖项。
我在我的 pom.xml 中添加了 Wildfly Swarm 2017.12.1。我没有手动添加分数,因为所有分数都是自动发现的:
2018-01-03 14:37:34,976 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Logging - STABLE org.wildfly.swarm:logging:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS with JAXB - STABLE org.wildfly.swarm:jaxrs-jaxb:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI Configuration - STABLE org.wildfly.swarm:cdi-config:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: CDI - STABLE org.wildfly.swarm:cdi:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Hibernate Validator - STABLE org.wildfly.swarm:hibernate-validator:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS with Validation - STABLE org.wildfly.swarm:jaxrs-validator:2017.12.1
2018-01-03 14:37:34,982 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JCA - STABLE org.wildfly.swarm:jca:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Datasources - STABLE org.wildfly.swarm:datasources:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Bean Validation - STABLE org.wildfly.swarm:bean-validation:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Elytron - STABLE org.wildfly.swarm:elytron:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JAX-RS - STABLE org.wildfly.swarm:jaxrs:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: JPA - STABLE org.wildfly.swarm:jpa:2017.12.1
2018-01-03 14:37:34,983 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Transactions - STABLE org.wildfly.swarm:transactions:2017.12.1
2018-01-03 14:37:34,984 INFO [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Undertow - STABLE org.wildfly.swarm:undertow:2017.12.1
2018-01-03 14:37:34,984 WARN [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction: Swagger - UNSTABLE org.wildfly.swarm:swagger:2017.12.1
招摇分数不稳定。我不确定为什么,但无论如何。它被添加了,后来我得到了一些错误。我收到的错误消息是这样的:
2018-01-03 14:37:46,545 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 11) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: RESTEASY003945: Unable to instantiate MessageBodyWriter
.... long stacktrace ...
Caused by: java.lang.RuntimeException: RESTEASY003945: Unable to instantiate MessageBodyWriter
... long stacktrace ...
Caused by: org.jboss.weld.exceptions.AmbiguousResolutionException: WELD-001318: Cannot resolve an ambiguous dependency between:
- Managed Bean [class io.swagger.jaxrs.listing.SwaggerSerializers] with qualifiers [@Any @Default],
- Managed Bean [class io.swagger.jaxrs.listing.SwaggerSerializers] with qualifiers [@Any @Default]
... stacktrace...
如您所见,它在类路径中找到了两次 SwaggerSerializers,所以我猜这是 Swarm 安装 swagger fraction 的问题。 也许如果我手动添加所有依赖项,那么它可能会奏效。但我认为这不是一个好的解决方案。 如 https://issues.jboss.org/browse/SWARM-271 中所述,这是一个错误。
有什么办法可以解决这个问题吗?
我找到了解决方案。我只需要在项目的 pom 中添加 <scope>provided</scope>
到 swagger 的依赖项。