Install
Download releases version from https://github.com/T-baby/MongoDB-Plugin/releases/tag/1.0.3
maven(First release github version. Maven version is generally one or two days later than the GitHub version )
<dependency>
<groupId>com.cybermkd</groupId>
<artifactId>MongodbPlugin</artifactId>
<version>1.0.8.2</version>
</dependency>
Dependency
This project depend on mongo-java-driver, fastjson and SLF4J (MongoDB official suggestion). If use JFinal or other plugins, please load relevant project package. See: https://github.com/T-baby/MongoDB-Plugin/blob/master/pom.xml
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
Initialization
Combine with JFinal
Load in configPlugin
MongoJFinalPlugin jFinalPlugin = new MongoJFinalPlugin();
jFinalPlugin.add("127.0.0.1",27017);
jFinalPlugin.setDatabase("test");
me.add(jFinalPlugin);
Combine with Resty
Load in configPlugin
MongoRestyPlugin mongoRestyPlugin = new MongoRestyPlugin();
mongoRestyPlugin.add("127.0.0.1",27017);
mongoRestyPlugin.setDatabase("test");
pluginLoader.add(mongoRestyPlugin);
Combine with ICEREST
Load in configPlugin
MongoIceRestPlugin mongoIcePlugin = new MongoIceRestPlugin();
mongoIcePlugin.add("127.0.0.1",27017);
mongoIcePlugin.setDatabase("test");
pluginLoader.add(mongoIcePlugin);
Other frameworks usage
Almost be compatible with most mainstream frameworks
MongoPlugin mongoPlugin=new MongoPlugin();
mongoPlugin.add("127.0.0.1",27017);
mongoPlugin.setDatabase("test");
MongoClient client = mongoPlugin.getMongoClient();
MongoKit.INSTANCE.init(client, mongoPlugin.getDatabase());
client.close();
More information can see https://t-baby.gitbooks.io/mongodb-plugin/content/geng\_hao\_de\_lian\_jie.html