Reputation: 2768
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).
Module A structure(dependency, packaged as jar): src/main/resources/META-INF/resources/jsp/*.jsp
Module B structure(main module, packaged as war, jsp in here override the ones in Module A): src/main/webapp/jsp/*.jsp
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/
Also, this is an example on how I have jsp set up: https://github.com/ghillert/spring-boot-jsp-demo
Upvotes: 16
Views: 3858
Reputation: 1
As of 2023, the option to enable compiler.automake.allow.app.running
is under the file/settings/advanced settings/
with a new name Allow auto-make to start even if developed application is currently running
.
Upvotes: 0
Reputation: 1
Now is 2022, i am using spring boot 2.2.6 with embed tomcat server, we can manually set tomcat context parameter :
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
protected void postProcessContext(Context context) {
((StandardJarScanner)context.getJarScanner()).setScanManifest(false);
context.setAddWebinfClassesResources(true);
context.setReloadable(true);
Wrapper jsp = (Wrapper) context.findChild("jsp");
jsp.addInitParameter("modificationTestInterval", "0");
jsp.addInitParameter("development","true");
}
};
}
here, setAddWebinfClassesResources parameter is important ,base on tomcat user guide, This attribute controls if, in addition to static resources being served from META-INF/resources inside web application JAR files, static resources are also served from WEB-INF/classes/META-INF/resources. This only applies to web applications with a major version of 3 or higher. Since this is a proprietary extension to the Servlet 3 specification, it is disabled by default. To enable this feature, set the attribute to true.
Upvotes: 0
Reputation: 1356
An option could be to use the Gradle Cargo Plugin or Maven Cargo plugin in order to redeploy your files onto Tomcat (all files can be redeployed, including resource files).
File reloading is not automatic. You have to manually run the relevant task/goal, CargoRedeployLocal or cargo:redeploy for Gradle and Maven builds respectively.
If restarting everything takes a long time though, redeploying using the Cargo plugin might help speed things up.
Upvotes: 1
Reputation: 933
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
Another option: https://github.com/spring-projects/spring-loaded
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.
Upvotes: 5
Reputation: 18430
This is highly likely the same as: https://stackoverflow.com/a/8656527/696632
All resources in classpath are subject to a cache. You should evaluate the answer.
Upvotes: 4