简体   繁体   English

如何配置项目以在角度,spring-boot,maven项目中自动重新加载浏览器

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

相关问题 angular2弹簧靴项目结构 - angular2 spring-boot project structure 将spring-boot项目配置为使用SSL后的响应为空 - Empty response after configure the spring-boot project to use SSL UnsatisfiedDependencyException 试图在 eclipse 中配置一个基本的 spring-boot 项目 - UnsatisfiedDependencyException trying to configure a basic spring-boot project in eclipse 如何在 IDEA Intellij 上使用 Spring-boot 进行自动重新加载 - how to make auto reload with Spring-boot on IDEA Intellij Maven-在当前项目中未找到前缀&#39;spring-boot&#39;的插件 - Maven- No plugin found for prefix 'spring-boot' in the current project spring-boot 项目中的错误 - Errors in spring-boot project 如何配置spring-boot项目以与内存空间数据库一起进行测试? - How to configure spring-boot project to work with inmemory spatial database for tests? 如何正确编写 Docker 文件来构建 war 文件并运行 spring-boot maven 项目? - How write correctly a Docker file to build war file and run spring-boot maven project? 如何为 spring 启动项目配置 spring 安全性 - how to configure spring security for spring boot project 如何在不改变原有pom的情况下,在新的spring-boot项目中添加spring-boot jar作为依赖 - How to add a spring-boot jar as a dependency in a new spring-boot project without changing the original pom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM