Dart / Flutter使用HTTP连接到Springboot API [英] Dart/Flutter using HTTP to connect to Springboot api

查看:270
本文介绍了Dart / Flutter使用HTTP连接到Springboot API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用http(dart包)连接到本地部署的springboot api,
。但是,应用程序抛出连接被拒绝错误111,并显示了错误的端口

I'm using http (dart package) to connect to a locally deployed springboot api, However, the application throws Connection refused error 111 and shows the wrong port

尝试打开端口以查看是否有帮助,用计算机ipm替换了本地主机ip spring更改了springboots端口,但问题仍然存在。

Tried opening the port to see if that helped, replaced local host with the computers ipm changed springboots port but the problem is still there.

连接到服务器的线路

final response = await http.get('http://localhost:8080/api/v1/alltables');

控制台日志错误:

ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (27342): SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 49588


推荐答案

使用10.0.2.2。

Change localhost with 10.0.2.2.

这篇关于Dart / Flutter使用HTTP连接到Springboot API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆