Android Studio connects to Tomcat server in Springboot Failed to connect to XXX

        After ensuring that the Springboot project can run correctly, click on the android project to run

         An error similar to Failed to connect to /127.0.0.1:8080 occurs. The reason is that the android emulator uses itself as localhost, that is, localhost or 127.0.0.1 is used in the code to access, both of which access the emulator itself, and the backend is not on the mobile phone. run on.

        If you encounter this kind of error, you can change the ip to the local address. Windows can execute: ipconfig command to find the local ip modification. Mac can enter ifconfig in the terminal, find the ip after inet, and modify it to the corresponding file. That’s it.

Guess you like

Origin blog.csdn.net/Dragon_hopex/article/details/132524595