使用Spring MVC和Boot刷新静态内容 [英] Refreshing static content with Spring MVC and Boot

查看:181
本文介绍了使用Spring MVC和Boot刷新静态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估Spring MVC&用于构建Web应用程序的Boot和AngularJs。我遇到的问题是,当我对静态内容(html,js,css)进行修改时,我每次都必须重新启动应用程序。我希望有一种解决方法,因为重新启动静态内容更改的整个应用程序效率不高。我尝试过的每个其他Web应用程序框架都允许动态更新静态内容文件(甚至只是Spring MVC和普通的旧WAR应用程序)。

I'm evaluating Spring MVC & Boot and AngularJs for building web applications. I've run into the problem that when I make modifications to my static content (html, js, css), I have to restart the application every time. I hope there is a some way of solving that because restarting the whole application for static content changes is not efficient. Every other web app framework I've tried allows updating static content files on the fly(even just Spring MVC and plain old WAR application).

我已经设置了我的项目来自使用Spring Boot Actuator构建RESTful Web服务指南( http://spring.io/guides/gs/actuator -service / )。基本上它使用Spring Boot和MVC控制器来创建REST服务。另外,我使用了使用AngularJS使用RESTful Web服务指南( http://spring.io / guides / gs / consumption-rest-angularjs / )使用AngularJS构建前端。它创建一个显示REST服务响应的网页。我所做的唯一改变是请求发送到我的应用程序而不是 http://rest-service.guides .spring.io /问候。我的静态内容存储在src / main / resources / public文件夹中。此设置正常工作,但它不会重新加载静态内容。

I've setup my project from "Building a RESTful Web Service with Spring Boot Actuator" guide (http://spring.io/guides/gs/actuator-service/). Basically it uses Spring Boot and MVC controllers to create a REST service. In addition, I've used "Consuming a RESTful Web Service with AngularJS" guide (http://spring.io/guides/gs/consuming-rest-angularjs/) to build a frontend with AngularJS. It creates a web page that displays the response from the REST service. The only change I've made is that the requests are made to my application instead of "http://rest-service.guides.spring.io/greeting". My static content is stored in "src/main/resources/public" folder. This setup works correctly except it doesn't reload static content.

推荐答案

文档说所有现代IDE都允许重新加载静态资源并且通常还有Java类更改的热交换( http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-hotswapping )。这是真的。 Eclipse默认情况下或多或少都会这样做,而且我不是IntelliJ用户,但据我所知,您可以将其配置为自动构建。

The docs say "all modern IDEs allow reloading of static resources and usually also hot-swapping of Java class changes" (http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-hotswapping). It's true. Eclipse does it more or less by default, and I'm not an IntelliJ user, but from what I understand you can configure it to build automatically as well.

这篇关于使用Spring MVC和Boot刷新静态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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