简体   繁体   English

尝试将请求 /api/v1/mega/building 从 localhost:4200 代理到 http://localhost:8080 时发生错误(ECONNREFUSED)

[英]Error occurred while trying to proxy request /api/v1/mega/building from localhost:4200 to http://localhost:8080 (ECONNREFUSED)

it's my first time using Java backend and angular front end.这是我第一次使用 Java 后端和 angular 前端。 I'm trying to build and run this project but I'm having this error: "[HPM] Error occurred while trying to proxy request /api/v1/mega/building from localhost:4200 to http://localhost:8080 (ECONNREFUSED)"我正在尝试构建和运行此项目,但出现此错误:“[HPM] 尝试将请求 /api/v1/mega/building 从 localhost:4200 代理到 http://localhost:8080 时发生错误( ECONNREFUSED)"

I ran.\gradlew.bat build to build the Java Application and the run npm install and npm run start on the angular and node js code.. I ran.\gradlew.bat build to build the Java Application and the run npm install and npm run start on the angular and node js code..

Do I have to start the Java server in some way after building the project?在构建项目后,我是否必须以某种方式启动 Java 服务器?

Here is my code:这是我的代码:

main.java主.java


import com.nortal.mega.persistence.BuildingRepository;
import com.nortal.mega.persistence.entity.BuildingDbo;
import lombok.AllArgsConstructor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;

import java.util.Arrays;

@AllArgsConstructor
@SpringBootApplication
public class Main {

    private final BuildingRepository buildingRepository;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

proxy.conf.json I have tried changing the target to 127.0.0.1, [::] all to no avail proxy.conf.json 我尝试将目标更改为 127.0.0.1, [::] 都无济于事

    "/api/*": {
        "target": "http://localhost:8080",
        "secure": false,
        "loglevel": "debug"
    }
}

Sounds like your backend is just not running.听起来你的后端只是没有运行。 To start a spring boot application:要启动 spring 引导应用程序:

./gradlew bootRun

from the root of your java application从 java 应用程序的根目录

edit: Looks like you are on Windows, so it would be something like编辑:看起来你在 Windows,所以它会像

.\gradlew.bat bootRun

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Angular 连接到 Spring 的 CORS 错误(localhost 8080 &lt;--&gt; localhost 4200) - CORS error connecting Angular to Spring (localhost 8080 <--> localhost 4200) 带 Angular 的弹簧靴。 CORS 策略已阻止从源“http://localhost:4200”访问“http://localhost:8080/”处的 XMLHttpRequest - Spring boot with Angular. Access to XMLHttpRequest at 'http://localhost:8080/' from origin 'http://localhost:4200' has been blocked by CORS policy o.apache.coyote.http11.Http11Processor 处理请求错误 | 打开 localhost:8080 时 - o.apache.coyote.http11.Http11Processor Error processing request | while opening localhost:8080 CORS 策略已阻止从 localhost:4200 在 localhost:8080 访问 XMLHttpRequest - Access to XMLHttpRequest at localhost:8080 from localhost:4200 has been blocked by CORS policy Angular 6 + Spring Boot:错误:“来自源‘http://localhost:4200’已被 CORS 策略阻止” - Angular 6 + Spring Boot: Error: "from origin 'http://localhost:4200' has been blocked by CORS policy" http:// localhost:8080 / mix / api / get / holidaytype / all响应CoSend&#39;GET&#39;请求发送到URL:de:405 - http://localhost:8080/mix/api/get/holidaytype/all Response CoSending 'GET' request to URL :de : 405 尝试在POSTMAN中获取一个主题http:// localhost:8080 / topics?id = 1。 得到了以下错误 - Trying to GET one topic http://localhost:8080/topics?id=1 in POSTMAN. Got the following error 我在尝试在 sts4 上发出获取请求时,在 postman 控制台上不断收到“错误:连接 ECONNREFUSED 192.168.0.29:8080” - I keep getting "Error: connect ECONNREFUSED 192.168.0.29:8080 " On postman console while im trying to make a get request on sts4 错误:XHR 加载失败:GET “http://localhost:8080/home” in agular - Error: XHR failed loading: GET “http://localhost:8080/home” in agular 本地主机api请求的HTTP失败响应:0未知错误-Angular - Http failure response for localhost api request: 0 Unknown Error - Angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM