Answer the question
In order to leave comments, you need to log in
How to substitute collection name from environment variables in spring data?
Actually there is a Mongolian base, it has some kind of collection.
There is an environment variable (or a string in application.properties - it doesn't matter in this case) "collections.collection1" which is equal to what.
There is this model:
@Data
@Document(collection = "${collections.collection1}")
public class MyModel {
@Id
private ObjectId _id;
@Field
private String myField
//...
@Override
public boolean equals(Object o) {
//...
}
@Override
public int hashCode() {
//...
}
}
Invalid collection name specified 'mymongodb.${collections.collection1}those. the variable is not substituted here (for example, in RestController, such a substituted works fine).
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question