当前位置:网站首页>Share an experience of self positioning + problem solving
Share an experience of self positioning + problem solving
2022-06-27 20:56:00 【I am fat tiger】
The problem background
Recently in use Java Of Springboot Framework development a project , encounter 2 individual An unsolved problem . At that time, I was confused by this problem , To solve this 2 individual bug Explored for hours , Finally, I fell down and groped by myself , Then locate the problem and solve it ! Although it turns out that the solution to the problem is simple , But position yourself , The process of analyzing problems , And then solve the problem , Full of sense of achievement , ha-ha , So share the whole process ~
Problem summary
All in all 2 A question :
first : Wrote a very basic Controller Class and then access , The result is always 404
the second : First, in the Maven It is written in the parent project Swagger Configuration of , Created 2 individual Maven Sub project .
- In the sub project A This parent class is introduced in , It can be accessed normally swagger Of web Interface .
- Sub project B This parent class is also introduced , Sub project B Medium Pom.xml Configuration and sub projects A It's almost the same , But it can not be accessed normally swagger Of web Interface ...
Actual problem description
This is the description of the first problem
- It was written at that time Controller
- According to common sense , I just need external access
http://127.0.0.1:8002/oss/file/wYou can get the expected return value , However, the actual results are as follows , return 404 error
3. Start troubleshooting
- Use postman Debug interface , postman The interface is as follows
- Because multiple services are started at the same time , So I first check whether the service visited is correct . Confirmed , The startup port of the target service is 8002
server.port=8002, then postman Also visited 8002 port - Confirm whether the access route is correct First, it looks like postman The requested route seems to be ok , The route exactly matches . But after several actual requests , It turns out that 404 after , Manually copy the route in the code to postman On , Prevent problems caused by dazzle or Chinese characters . The results have not changed , still 404 ~
- The suspicion is idea The cache problem of ? With this skepticism , Try to restart idea Several times , The result remains the same , Ah , At this point, the mentality is a little impatient
- I have no idea , Try Baidu
After reading this post written by the great God , Suddenly, I have some ideas , So check the application @ComponentScan annotation . It is no problem to simply read the notes , Then try to look at the package where the file is located , Find out ...
- Problem analysis
After investigation and positioning , The problem is obvious , The reason is that the @ComponentScan The internal configuration is incorrect !( When writing the package name, it should be com.atguuigu.oss, But an extra one u Turned into com.atguuigu.oss)
because @ComponentScan The configuration inside does not correspond to the actual package name , So when the application starts , Spring The... Under the correct package name directory is not automatically loaded Controller file , So external access will occur 404, Logical ~
- Try to solve the problem
Because the post just said : If not configured @ComponentScan, Springboot It will automatically load all components under the package where the startup class is located and its sub packages
- So first we will start the above class
@ComponentScan(basePackages = "com.atguigu")This sentence has been deleted , Verify if it is normal . After restart verification , Interface access is normal , hahaha~
- The operation just now , Initial results have been achieved . But another problem is swagger-ui Of web Interview questions . Hold the idea of following the vine and feeling the melon , Guess access swagger This is probably the same reason !
Just now it was directly removed @ComponentScan The way to solve the problem , Another way is to @ComponentScan(basePackages = "com.atguigu") The configuration inside should be consistent with the package name .
Operating results : After the change , New services swagger Successful visit !!!
Today's summary
- Although it looks like a long and minute statement Problems encountered in the troubleshooting of , then If it is actually solved, it will be changed to a letter (
It is estimated that someone should spray such vegetables , Just because of a letter , It will take hours to troubleshoot ?) - Want to pass this article , Share your solutions to the problems you encounter : Check step by step + solve the problem ~
- Share a few famous words :
- I don't know the truth , Only the body in this mountain !
- Mountains and rivers lead nowhere , Another village !
Because when writing this article , I realized the connotation of these two poems , haha~
- Share today's insights
- If you're in a bad mood , You need to calm down first , And then do something else , Otherwise, you will get half the result !
- Don't worry when things happen , Try to be calm , This will keep the brain calm , See things rationally . There needs to be a kind of “ Mount Tai collapses in front of us, but its color remains the same , The elk is fond of the left but not the eye ” State of mind !
边栏推荐
- Paste source layer and history layer of data warehouse system
- Database index
- Linux system plays Oracle database multi table query connection query with a smile
- [STL programming] [common competition] [Part 2]
- 本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
- QT Chinese garbled code
- Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
- Graduation design of police report convenience service platform based on wechat applet
- SQL reported an unusual error, which confused the new interns
- UOS prompts for password to unlock your login key ring solution
猜你喜欢

一场分销裂变活动,不止是发发朋友圈这么简单

润迈德医疗开启招股:未有基石投资者参与,亏损金额翻倍增长

Runmaide medical opened the offering: without the participation of cornerstone investors, the amount of loss doubled
I haven't thought about the source for some time. After upgrading to the latest version 24, the data encryption problem is repeatedly displayed

云原生安全指南: 从零开始学 Kubernetes 攻防

Dictionary tree (review)

redis数据结构

Type the URL to the web page display. What happened during this period?

It took me 6 months to complete the excellent graduation project of undergraduate course. What have I done?

No wonder people chose apifox instead of postman
随机推荐
Database transactions
Redis 大 key 问题处理总结
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
灵活的IP网络测试工具——— X-Launch
难怪大家丢掉了postman而选择 Apifox
Redis persistence
Linux system Oracle 19C OEM monitoring management
Postman Chinese tutorial (postman Chinese version)
308. 2D area and retrieval - variable segment tree / hash
Pfsense plus22.01 Chinese customized version release
This is the same as data collection. Can you define a parameter as last month or the previous day, and then use this parameter in SQL?
Postman 汉化教程(Postman中文版)
OpenSSL client programming: SSL session failure caused by an obscure function
[STL programming] [common competition] [Part 2]
Wechat IOS version 8.0.24 update release cache subdivision cleaning Online
谈谈我写作生涯的画图技巧
元宇宙虚拟数字人离我们更近了|华锐互动
展现强劲产品综合实力 ,2022 款林肯飞行家Aviator西南首秀
Web APLS phase - Section 14 - local storage
Flutter隐藏AppBar的返回按钮