我指定@MongoEntity集合名称如下:
@MongoEntity(collection = "collection_name_from_properties")
但是我想从应用程序中指定它。属性文件,就像我对类属性所做的那样:
@ConfigProperty(name = "application_property_param")
String myConfigParam;
我试过,运气不好,就像我在春天做的那样:
@MongoEntity(collection = "${collection_name_from_properties}")
你知道如何实现它吗?
@MongoEntity
是Quarkus的一个相对较新的特性,据我所知,使用Panache无法完成此功能。
如果你想使用Panache,最好的办法是暂时硬编码所有的集合名称,直到一个新的更新可能解决这个问题。
但是,如果您需要更高级的Mongo操作,我建议您使用Mongo Client。
有点晚了,但也许能帮助到别人。你有一个额外的字符"$"而不是
@MongoEntity(collection = "${collection_name_from_properties}")
应该是这样的
@MongoEntity(collection = "{collection_name_from_properties}")