因为在mongodb-driver-sync和mongodb-driver-core中依赖的bson的jar包是3.6.4版本,将其排除后依赖4.0.4后可以不报错了
org.mongodb mongodb-driver-sync 4.0.4 org.mongodb mongodb-driver-core org.mongodb bson org.mongodb bson 4.0.4
如果不单独引入4.0.4的mongodb-driver-core,mongoClient = MongoClients.create(httpUrl);会报以下错误:
The type com.mongodb.MongoClientSettings cannot be resolved. It is indirectly referenced from required .class files org.mongodb mongodb-driver-core 4.0.4 org.mongodb bson