Operation method of integrating mongodb with sprint boot

Mongodb is one of the first popular non relational databases, and it is also widely used. It is generally used for offline data analysis, and most of it is placed on the intranet. Because many companies use cloud services, the servers open their Internet addresses by default. As a result, a large number of mongodbs were attacked and their data deleted due to configuration vulnerabilities a while ago, which attracted people's attention. If you are interested, you can see this article: Reflection on the feast of killing mongodb: more than 33000 databases were invaded and blackmailed, It also shows that many companies use mongodb extensively in their production.

Introduction to mongodb

Mongodb (from the English word "humongous", which means "huge" in Chinese) )It is an open source database that can be applied to enterprises of all sizes, industries and applications. Database based on distributed file storage. Written in C + +. It aims to provide scalable high-performance data storage solutions for web applications. Mongodb is a high-performance, open source, schema free document database. It is a popular NoSQL database at present.

Mongodb is a product between relational database and non relational database. It is the most functional and relational database among non relational databases. The data structure he supports is very loose, which is a bjson format similar to JSON, so it can store more complex data types. Mongo's biggest feature is that the query language he supports is very powerful. Its syntax is a bit similar to the object-oriented query language. It can almost realize most functions similar to single table query of relational database, and also supports indexing of data.

The traditional relational database is generally composed of three hierarchical concepts: database, table and record. Mongodb is composed of database, collection and document object (document) consists of three levels. Mongodb has no column, row and relationship concepts for tables in relational databases, which reflects the characteristics of schema freedom.

A record in mongodb is a document. It is a data structure composed of fields and value pairs. Mongodb documents are similar to JSON objects. Field values may include other documents, arrays, and document arrays. Mongodb supports OS X, Linux, windows and other operating systems, and provides drivers for Python, PHP, ruby, Java and C + + languages. The community also provides support for Erlang and Net and other platforms.

MySQL is suitable for storing a large amount of data without fixed format, such as log, cache, etc. It has weak support for things, and is not suitable for complex multi document (multi table) cascading queries. This paper demonstrates that mongodb version is 3.4.

I recently took over a springboot project. I need to add some requirements to the original project, using mongodb. Let's take a look at the road of integration!

1. First POM Introducing mongodbde dependency jar package into XML

2. Create entity class

3. Dao layer operation mongodb code

4. In application Set relevant configuration information of monggodb database in properties

The relevant information configuration has been completed. The test verifies that the interaction with the database is correct!

summary

The above is the operation method of sprint boot integration mongodb introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>