I am getting the following error:
at com.aks.springStorage.SpringStorageApplication.main(SpringStorageApplication.java:22) [classes/:na]
Caused
@Document(collation="company")
This looks like a typo and the cause of your issue. You try to set collection name, but instead of collection you use collation property: https://docs.mongodb.com/manual/reference/collation/
The correct form of annotation would be:
@Document(collection = "company")
public class Company {
// ...
}
Or simpler – since value
is an alias for collection
:
@Document("company")
public class Company {
// ...
}
You can even completely omit collection name. In that case Spring will use class name as collection name:
@Document // name of collection wil be "company", as per class name
public class Company {
// ...
}
The last example is why this was working for you with e.g. count queries, even though you did not provide collection name explicitly.