gpt4 book ai didi

quarkus Resteasy-Jackson 原生的空 json 结果

转载 作者:行者123 更新时间:2023-12-02 16:09:00 25 4
gpt4 key购买 nike

使用我的休息端点/init 测试 quarkus 应用程序

已安装的功能:[cdi、resteasy、resteasy-jackson]

我发现当将应用程序作为java(不是 native )运行时,然后检查 http://localhost:8080/init

{
"user": {
"username": "u name",
"firstName": "f name",
"lastName": "l name",
"email": null
},
"logoutUrl": "url!!!!"
}

作为原生,

像这样本地运行:包-Dnative -f pom.xml

然后运行./my-service-1.0-SNAPSHOT-runner:

它得到结果: http://localhost:8080/init

{}

Jackson 配置如下:

    @Singleton
public class RegisterCustomModuleCustomizer implements ObjectMapperCustomizer {

public void customize(final ObjectMapper objectMapper) {
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
}
}

也不异常(exception)。

InitData 定义如下,与普通 bean 类一样:

    public class InitData {

private .. some fields

可能缺少什么?它不应该对 native /java 起作用吗?

<小时/>

更新:

当作为java运行时,编译quarkus:dev -f pom.xml:

[INFO] Scanning for projects... [INFO] [INFO] ------------< my.compnay:my-service >------------ [INFO] Building my-service 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-service --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ my-service --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 41 source files to /home/me/projects/my-project/v2/my-service-quarkus/target/classes [INFO] [INFO] --- quarkus-maven-plugin:1.0.0.CR1:dev (default-cli) @ my-service --- Listening for transport dt_socket at address: 5005 2019-11-12 14:17:43,027 INFO [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation 2019-11-12 14:17:43,599 INFO [io.qua.arc.pro.BeanProcessor] (build-1) Found unrecommended usage of private members (use package-private instead) in application beans: - @Inject field my.compnay.application.InitResource#initFacadeService 2019-11-12 14:17:43,658 INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 631ms 2019-11-12 14:17:44,104 INFO [io.quarkus] (main) Quarkus 1.0.0.CR1 started in 1.260s. Listening on: http://0.0.0.0:8080 2019-11-12 14:17:44,105 INFO [io.quarkus] (main) Profile dev activated. Live Coding activated. 2019-11-12 14:17:44,105 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jackson]

然后点击:http://localhost:8080/init

2019-11-12 14:19:52,423 INFO [com.dis.pla.app.ser.fil.LoggingFilter] (vert.x-worker-thread-1) Request GET /init from IP 0:0:0:0:0:0:0:1:48810 2019-11-12 14:19:52,425 INFO [com.dis.pla.app.InitResource] (vert.x-worker-thread-1) Init with user f name my.compnay.api.UserData@37ac6925

--

最佳答案

@RegisterForReflection (来自 here )是在数据对象上使用的注释,如果您的资源不直接返回该数据对象。

即就我而言:

  @GET
public Response getInit(

因此,除非您输入以下内容,否则它不会固有地工作:

@RegisterForReflection
class InitData { ...

但仍然如此。

我想我应该是一个bug。它的行为方式都应该相同。是否是本地人。

关于quarkus Resteasy-Jackson 原生的空 json 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58825073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com