[英]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.