mars
mars copied to clipboard
mars-springboot 模块优化建议
1 减少对 现有spring-boot-autoconfigure 的依赖 目前 spring-boot-autoconfigure 内置有 mongodb 驱动 ,可能会遇到 与 mars 内置驱动版本不一致的情况 这会导致 生成因为 spring 相关注入 原生的MongoClient 等前置依赖 失败 。最终导致Mars 的注入失败 。 所以需要剥离开 只依赖一些 配置文件 。
2 补充说明 在 spring-boot 项目中 MongoDB 的版本会被 spring - parent 依赖的数据库版本覆盖 。
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.mongodb.client.internal.MongoClientImpl.createCluster(MongoClientImpl.java:208)
The following method did not exist:
'com.mongodb.internal.connection.Cluster com.mongodb.internal.connection.DefaultClusterFactory.createCluster(com.mongodb.connection.ClusterSettings, com.mongodb.connection.ServerSettings, com.mongodb.connection.ConnectionPoolSettings, com.mongodb.connection.StreamFactory, com.mongodb.connection.StreamFactory, com.mongodb.MongoCredential, com.mongodb.event.CommandListener, java.lang.String, com.mongodb.MongoDriverInformation, java.util.List)'
The method's class, com.mongodb.internal.connection.DefaultClusterFactory, is available from the following locations:
jar:file:/repository/org/mongodb/mongodb-driver-core/4.11.1/mongodb-driver-core-4.11.1.jar!/com/mongodb/internal/connection/DefaultClusterFactory.class
The class hierarchy was loaded from the following locations:
com.mongodb.internal.connection.DefaultClusterFactory: file:/repository/org/mongodb/mongodb-driver-core/4.11.1/mongodb-driver-core-4.11.1.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.mongodb.internal.connection.DefaultClusterFactory
Process finished with exit code 1
- 目前已经解决 springboot 2.x 版本的兼容 。
- 针对 springboot 3.x 以上功能,也有一定的兼容性 。但是 针对 ssl 这种不友好 。