java - Quarkus + 子类 + ClassCastException
问题描述
我正在使用 Quarkus 的 vert.x 扩展,我想继承 WebClient
@Inject
Vertx vertx;
private CustomWebClient usersApiClient;
@PostConstruct
void initialize() {
this.usersApiClient = (CustomWebClient) WebClient.create(vertx, new WebClientOptions()....)
}
现在 CustomWebClient 是空的,只是扩展了 Web 客户端
public class CustomWebClient extends io.vertx.mutiny.ext.web.client.WebClient {
但是我在运行时得到一个 ClassCastException (例如在 quarkus:dev 中)
Caused by: java.lang.ClassCastException: class io.vertx.mutiny.ext.web.client.WebClient
cannot be cast to class xxx.CustomWebClient (io.vertx.mutiny.ext.web.client.WebClient is in
unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @760f1081;
xxx.CustomWebClient is in unnamed module of loader.
io.quarkus.bootstrap.classloading.QuarkusClassLoader @55be9b4e)
我需要在类加载器中注册这个类吗?
解决方案
推荐阅读
- python - 如何找到两个向量之间的角度,范围从 0 rad 到 2 rad,而不是使用 arccos 函数的内角
- python - Python Dataframe 使用线性关系过滤数据
- machine-learning - pytorch torchvision.datasets.ImageFolder FileNotFoundError:找不到类 .ipynb_checkpoints 的有效文件
- html - Oracle Apex HTML CSS 在两个子区域之间插入垂直线
- database - 在 Oracle SQL developer 18.x 中配置 GIT
- rust - 如何编写只能与某种类型的迭代器一起使用的迭代器扩展?
- python-3.x - Python3 - 无法根据来自对象检测过程的输入正确启动输出设备
- java - 仅当在 Scala 中使用不相关的对象时才同步块
- math - 在 OBB(定向边界框)上查找特定点
- sql - SQL 更新列