In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to remove the _ class attribute field from Spring Data MongoDB. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Oyhk study notes
Spring Data MongoDB removes the _ class attribute field
I believe that if you use java to operate mongodb, many people will choose spring data mongodb. I am also one of them who chose spring data mongodb. I also like spring things very much. Ha
In the beginning, I used spring data mongodb, and when I added a piece of data, I used MongoVUE to query the data. As shown in the picture
See the _ class property?
Briefly talk about this field, why should spring data mongodb be added, probably in order to query the type conversion of the data. Let's check it out again.
However, you will find that with and without this field, when querying data, it can also be converted into an object. So... It's better not to, not only the data is big, but only a little..
But it seems that I am not used to this field. Get rid of it.
The following two properties are removed from the _ class field. Personally, I like to use xml configuration.
The first is annotation.
@ Configuration public class SpringMongoConfig {public @ Bean MongoDbFactory mongoDbFactory () throws Exception {return new SimpleMongoDbFactory (new Mongo (), "database");} public @ Bean MongoTemplate mongoTemplate () throws Exception {/ / remove _ class MappingMongoConverter converter = new MappingMongoConverter (mongoDbFactory (), new MongoMappingContext ()); converter.setTypeMapper (new DefaultMongoTypeMapper (null)); MongoTemplate mongoTemplate = new MongoTemplate (mongoDbFactory (), converter); return mongoTemplate;}}
The second way: xml configuration
All right, now that the configuration is complete, I'll run the code that inserts the data again, and then take a look at the situation. Okay, the following figure
Are you comfortable now? the field of _ class is gone. OK, it's done.
The above is how Spring Data MongoDB removes the _ class attribute field. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.