Spring Data MongoDB Repository with custom collection name
问题 I am using Spring Data for MongoDB and I need to be able to configure collection at runtime. My repository is defined as: @Repository public interface EventDataRepository extends MongoRepository<EventData, String> { } I tried this silly example: @Document(collection = "${mongo.event.collection}") public class EventData implements Serializable { but mongo.event.collection did not resolve to a name as it does with a @Value annotation. A bit more debugging and searching and I tried the following