In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is the MongoDB pit encountered in the use of ExtentReports? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Because the reports generated by ExtentReports are high-end, ExtentReports is used in automation projects. The problems encountered and the process of solving them are as follows.
First of all, my automation project is springBoot+testNG.
After the introduction of ExtentReports, the MongoDB connection error is always reported when running automation:
Com.mongodb.MongoSocketOpenException: Exception opening socket
But my project didn't use MongoDB, so I looked at the dependency tree with mvn dependency:tree first.
It was found that extentreports did introduce it.
If you look at the log carefully, springBoot will start MongoDB normally after it starts.
Then I took a detour and thought it was a configuration problem. I tried to modify the configuration of MongoDB to see if I could connect properly, and found that the road was blocked.
Look at ExtentReports, only ExtentXReporter can use MongoDB, so in theory, I don't even need to use MongoDB.
So think differently: just don't let springBoot start MongoDB.
To query the scheme, it is OK to add the following annotations to the test class:
@ EnableAutoConfiguration (exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
But this is not very elegant, and it is troublesome to add this annotation to every subsequent test class; I tried to liberate the note to the test class inheriting its own testng parent class (which inherits AbstractTestNGSpringContextTests) and found that it didn't work.
Considering that springBoot startup will not start MongoDB before the introduction of ExtentReports, I can just get rid of the MongoDB dependency.
Com.aventstack
Extentreports
3.1.5
Org.mongodb
Mongodb-driver
Then run it again and found that the class ObjectId was not found in the error report. I guessed that it was the class in the package introduced by mongodb-driver, and restored it to check that it was indeed in mongdb-bson.
Finally, it is fine to introduce bson dependency separately.
Org.mongodb
Bson
3.8.2
--
In the second update, a similar problem was encountered. The startup error did not find a suitable data driver. Similarly, the spring-boot-starter-jdbc dependency was removed this time.
Org.springframework.boot
Spring-boot-starter-data-jpa
Org.springframework.boot
Spring-boot-starter-jdbc
After reading the above, have you mastered the method of the MongoDB pit encountered in the use of ExtentReports? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.