Tomcat/Spring boot 重载 META-INF/resources/jsp 文件(实时更新) [英] Tomcat/Spring boot reloading META-INF/resources/ jsp files (live updates)

查看:178
本文介绍了Tomcat/Spring boot 重载 META-INF/resources/jsp 文件(实时更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 spring boot/tomcat 实例中使用 jsp 时遇到问题.基本上,我在模块 A (A/src/main/resources/META-INF/resources/jsp) 中拥有所有 jsp 文件,并且该模块作为 jar 依赖项包含在模块 B(主模块,war 打包)中.问题是,当应用程序在调试模式下(在 Eclipse 或 IntelliJ Idea 中)运行时,模块 A 中的任何 jsp 文件都不会自动重新加载(在呈现的网页上看不到文件中的更改),只能重新启动tomcat 实际上重新加载文件并显示更改.模块 B 中被覆盖的 jsp 文件正在自行重新加载,只是模块 A 中的 jsp 文件有问题(可能是因为 META-INF/resources 文件夹).

I have a problem using jsp in spring boot/tomcat instances. Basically, I have all jsp files inside module A (A/src/main/resources/META-INF/resources/jsp) and this module is included into module B (main module, war packaging) as a jar dependency. The problem is, when app is running in debug mode (either in Eclipse or in IntelliJ Idea), none of the jsp files located in module A, are being auto reloaded(changes in file are not seen on the rendered webpage), only restart of tomcat actually reloads the files and shows the changes. The overriden jsp files in Module B are being reloaded themselves, just the jsp files in Module A are having problems(probably because of META-INF/resources folder).

模块A结构(依赖,打包成jar):src/main/resources/META-INF/resources/jsp/*.jsp

Module A structure(dependency, packaged as jar): src/main/resources/META-INF/resources/jsp/*.jsp

模块B结构(主模块,打包成war,这里jsp覆盖模块A):src/main/webapp/jsp/*.jsp

Module B structure(main module, packaged as war, jsp in here override the ones in Module A): src/main/webapp/jsp/*.jsp

我已经为此寻找了解决方案,但我最接近答案的是这个(使用 JRebel):https://zeroturnaround.com/论坛/主题/jsps-in-servlet-3-0-jars-are-not-reloading/

I have searched for a solution to this, but the closest I came to an answer was this(Using JRebel): https://zeroturnaround.com/forums/topic/jsps-in-servlet-3-0-jars-are-not-reloading/

此外,这是一个关于我如何设置 jsp 的示例:https://github.com/ghillert/spring-boot-jsp-demo

Also, this is an example on how I have jsp set up: https://github.com/ghillert/spring-boot-jsp-demo

推荐答案

我不知道它是否符合您的限制,但有这样的解决方案:https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3

I don't know if it fits your constraints but there is a solution like this out there : https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3

另一种选择:https://github.com/spring-projects/spring-loaded

我使用 JSF 和 Facelets,对于具有动态渲染的 Web 技术,热重载总是有点问题.所以除了 spring-boot-devtools 之外,我的建议是将静态内容开发过程与渲染相关过程分开.如果您只需要对 css、html、js 编辑进行热重载,那么大多数技术都会帮助您,但渲染相关的组件编辑会要求您时不时地重新构建重新部署您的应用程序.他们询问您的频率取决于您将使用的工具的质量.

I use JSF and Facelets and hot reload is always a bit problematic for web technologies which has dynamic rendering. So my suggestion apart from spring-boot-devtools will be separating static content development process from rendering related process. If you only need hot reload for css, html, js editing than most of technologies out there will help you but rendering related component editing going to ask you to rebuilt redeploy your app time to time. How frequently they going to ask you that depends on quality of the tool you will be using.

这篇关于Tomcat/Spring boot 重载 META-INF/resources/jsp 文件(实时更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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