[英]How to configure project to auto reload browser in angular, spring-boot, maven project
The project uses Maven, Spring Boot, Angular, Visual Studio Code editor. 该项目使用Maven,Spring Boot,Angular,Visual Studio Code编辑器。
How can I configure the project to reload the browser when angular files change? 角度文件更改时,如何配置项目以重新加载浏览器?
spring-boot with angular app 带有角度应用程序的弹簧靴
With this dependency in pom.xml, the browser reloads when java files change. 在pom.xml中具有此依赖性时,浏览器将在Java文件更改时重新加载。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
Client-Server Integration 客户端-服务器集成
Server and client projects are on ports 8080 and 4200 respectively. 服务器和客户端项目分别在端口8080和4200上。
The client project's server will be the "front end" (localhost:4200) and all requests will be served by this server except URLs with the pattern "/". 客户端项目的服务器将是“前端”(localhost:4200),所有请求都将由该服务器处理,但URL的模式为“ /”。
The client server at 4200 will proxy any "/" requests to the "backend" server (localhost: 8080). 位于4200的客户端服务器将代理任何“ /”请求到“后端”服务器(本地主机:8080)。
To configure this setup, create a file "proxy.conf.json" with the following contents. 要配置此设置,请创建包含以下内容的文件“ proxy.conf.json”。
{
"/" :{
"target" : "http://localhost:8080",
"secure" : false
}
}
Modify the “start” script in package.json: 修改package.json中的“开始”脚本:
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Start the "frontend" 启动“前端”
npm start
Start the "backend" 启动“后端”
mvn spring-boot:run
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.