gpt4 book ai didi

java - 如何配置 Spring Data 在保存到 Mongo DB 时使用对象的字符串版本?

转载 作者:行者123 更新时间:2023-12-01 11:07:00 25 4
gpt4 key购买 nike

我有一个代表 Artefact 的对象:

public class Artifact {

private final URI location;

public Artifact(URI location) {
this.location = location;
}
}

当我使用 MongoTemplate 保存它时,URI 会变成一个对象:

{ "location" : { "scheme" : "http", "authority" : "localhost:8080", "host" : "localhost", "port" : 8080, "path" : "/testFrontendURL", "schemeSpecificPart" : "//localhost:8080/testFrontendURL", "hash" : 331612143, "string" : "http://localhost:8080/testFrontendURL" }

但是,这可以仅由 URI 字符串表示:

{"location": "http://localhost:8080/testFrontendURL"}

如何配置 Spring Data 来执行此操作?

最佳答案

关于java - 如何配置 Spring Data 在保存到 Mongo DB 时使用对象的字符串版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32844675/

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