用于@BsonIgnore 的工件

Artifact to use for @BsonIgnore

我正在尝试为我写入库的服务抽象出我的核心对象。我有我需要理顺的所有其他工件,但不幸的是我找不到 @BsonIgnore 的工件。我正在使用 @BsonIgnore 忽略一些不应该添加到 bson 文档中的方法,因为实施服务将这些对象写入 MongoDb.

对于上下文,服务是使用 Quarkus 编写的,Mongo 对象是使用 Panache 处理的:

implementation 'io.quarkus:quarkus-mongodb-panache'

我正在创建的库主要只是一个简单的 pojo 库,在 Gradle 构建中没有什么特别之处。

我在 Maven Central 上找到了这个:https://mvnrepository.com/artifact/org.bson/bson?repo=novus-releases 但似乎不是正常版本,也没有解决问题。

如果有用,这是我的代码:

@Data
public abstract class Historied {
    /** The list of history events */
    private List<HistoryEvent> history = new ArrayList<>(List.of());

    /**
     * Adds a history event to the set held, to the front of the list.
     * @param event The event to add
     * @return This historied object.
     */
    @JsonIgnore
    public Historied updated(HistoryEvent event) {
        if(this.history.isEmpty() && !EventType.CREATE.equals(event.getType())){
            throw new IllegalArgumentException("First event must be CREATE");
        }
        if(!this.history.isEmpty() && EventType.CREATE.equals(event.getType())){
            throw new IllegalArgumentException("Cannot add another CREATE event type.");
        }

        this.getHistory().add(0, event);
        return this;
    }

    @BsonIgnore
    @JsonIgnore
    public HistoryEvent getLastHistoryEvent() {
        return this.getHistory().get(0);
    }

    @BsonIgnore
    @JsonIgnore
    public ZonedDateTime getLastHistoryEventTime() {
        return this.getLastHistoryEvent().getTimestamp();
    }
}

这是正确的依赖项 https://mvnrepository.com/artifact/org.mongodb/bson/4.3.3,但请检查您的特定版本