Skip to content

Commit 5fac012

Browse files
committed
refactor code
1 parent 7b433e7 commit 5fac012

17 files changed

+147
-72
lines changed

‎.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*#
2+
*.iml
3+
*.ipr
4+
*.iws
5+
*.jar
6+
*.sw?
7+
*~
8+
.#*
9+
.*.md.html
10+
.DS_Store
11+
.classpath
12+
.idea
13+
.metadata
14+
MANIFEST.MF
15+
bin
16+
build
17+
!/**/src/**/bin
18+
!/**/src/**/build
19+
build.log
20+
manifest.yml
21+
target

‎.idea/MongoDB-Java-Tutorials.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/jarRepositories.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/libraries/Maven__org_mongodb_mongo_java_driver_3_12_6.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/libraries/Maven__org_projectlombok_lombok_1_18_12.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/misc.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

‎Mongodb-Java-Tutorials.iml

-2
This file was deleted.

‎data/pom.xml

-23
This file was deleted.

‎mongodb-insert/pom.xml

-28
This file was deleted.

‎mongodb-connection/pom.xml renamed to ‎mongodb-java/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
<artifactId>mongodb-connection</artifactId>
6+
<artifactId>mongodb-java</artifactId>
77

88
<parent>
99
<artifactId>Mongodb-Java-Tutorials</artifactId>
@@ -12,17 +12,16 @@
1212
</parent>
1313

1414
<dependencies>
15-
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
1615
<dependency>
1716
<groupId>org.mongodb</groupId>
1817
<artifactId>mongo-java-driver</artifactId>
19-
<version>${mongodb.java.driver.version}</version>
18+
<version>3.12.6</version>
2019
</dependency>
2120

2221
<dependency>
2322
<groupId>org.projectlombok</groupId>
2423
<artifactId>lombok</artifactId>
25-
<version>${lombok.version}</version>
24+
<version>1.18.12</version>
2625
</dependency>
2726
</dependencies>
2827

‎mongodb-connection/src/main/java/com/hungcdev/connection/MongoDBConnection.java renamed to ‎mongodb-java/src/main/java/com/hungcdev/mongodb/connection/MongoDBConnection.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package com.hungcdev.connection;
1+
package com.hungcdev.mongodb.connection;
22

33
import com.mongodb.ConnectionString;
44
import com.mongodb.MongoClientSettings;
55
import com.mongodb.client.MongoClient;
66
import com.mongodb.client.MongoClients;
77
import com.mongodb.client.MongoDatabase;
8+
import org.bson.codecs.configuration.CodecRegistries;
89
import org.bson.codecs.configuration.CodecRegistry;
910
import org.bson.codecs.pojo.PojoCodecProvider;
1011

@@ -26,8 +27,8 @@ public void connectMongoDB(String ip, int port) {
2627

2728
public void connectMongoDBWithPOJOs(String ip, int port) {
2829
ConnectionString connectionString = new ConnectionString("mongodb://" + ip + ":" + port);
29-
CodecRegistry pojoCodecRegistry = fromProviders(PojoCodecProvider.builder().automatic(true).build());
30-
CodecRegistry codecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(), pojoCodecRegistry);
30+
CodecRegistry pojoCodecRegistry = CodecRegistries.fromProviders(PojoCodecProvider.builder().automatic(true).build());
31+
CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClientSettings.getDefaultCodecRegistry(), pojoCodecRegistry);
3132
MongoClientSettings clientSettings = MongoClientSettings.builder()
3233
.applyConnectionString(connectionString)
3334
.codecRegistry(codecRegistry)

‎data/src/main/java/com/hungcdev/data/Post.java renamed to ‎mongodb-java/src/main/java/com/hungcdev/mongodb/data/Post.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.hungcdev.data;
1+
package com.hungcdev.mongodb.data;
22

33
import lombok.*;
44

‎mongodb-insert/src/main/java/com/hungcdev/insert/InsertDocument.java renamed to ‎mongodb-java/src/main/java/com/hungcdev/mongodb/insertion/InsertDocument.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.hungcdev.insert;
1+
package com.hungcdev.mongodb.insertion;
22

3-
import com.hungcdev.connection.MongoDBConnection;
4-
import com.hungcdev.data.Post;
3+
import com.hungcdev.mongodb.connection.MongoDBConnection;
4+
import com.hungcdev.mongodb.data.Post;
55
import com.mongodb.client.MongoCollection;
66
import com.mongodb.client.MongoDatabase;
77

‎pom.xml

+1-8
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
<version>1.0</version>
1010

1111
<modules>
12-
<module>mongodb-connection</module>
13-
<module>data</module>
14-
<module>mongodb-insert</module>
12+
<module>mongodb-java</module>
1513
</modules>
1614

1715
<properties>
1816
<maven.compiler.source>11</maven.compiler.source>
1917
<maven.compiler.target>11</maven.compiler.target>
20-
21-
<root.version>1.0</root.version>
22-
23-
<mongodb.java.driver.version>3.12.6</mongodb.java.driver.version>
24-
<lombok.version>1.18.12</lombok.version>
2518
</properties>
2619

2720
</project>

0 commit comments

Comments
 (0)