我尝试在azure上部署java spring应用程序。 该应用程序使用本地MongoDB 4.0。我尝试将其替换为 Azure CosmosDB。连接正常,但运行我的应用程序测试会出现以下错误:
"http://org.springframework.data .mongodb.UncategorizedMongoDbException: Query failed with error code 2 and error message 'Projection operator not supported.' on server …http://...azure.com:10255 ; nested exception is com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'Projection operator not supported.'" Projection operator seems to be generated by MongoRepository class.
import org.springframework.data .mongodb.repository.MongoRepository;
import org.springframework.data .mongodb.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends MongoRepository<User, UUID>, UserRegexSearch{
public Optional<User> findByEmail(String email);
}
最佳答案
Azure Cosmos DB 的 MongoDB API 的 Protocol support 默认与 MongoDB 服务器版本 3.2 兼容,并且在 v3.4 的公共(public)预览版下兼容。目前不支持 4.0 版本,但请对以下 UserVoice 条目进行投票和评论:Support for transactions via Mongo 4.0 API
关于java - 如何修复 CosmosDB for MongoDB api 上的 'Projection operator not supported' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55920818/