2

Just like when you deploy in tomcat and you can access and modify the frontend without restarting the whole tomcat server, is there anyway to find where those files are and modify them (without need to compile again) for an app created with spring boot? I just have the jar, but I know should be a place where the tomcat deploys the files, any idea where is?

Thanks

jpganz18
  • 5,508
  • 17
  • 66
  • 115

2 Answers2

1

You can configure your app to serve static files from some folder of file system:

@Configuration
public class StaticResourceConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/files/**")
                .addResourceLocations("file:/opt/files/");
    }
}

for windows users the path would be: “file:///C:/MyDocs”

Rafael Zeffa
  • 2,334
  • 22
  • 20
0

you can get specific current path of execution inside the java runtime and then go from there. Knowing a standard WAR or EAR structure will help Check this one

Get the location of my web application context

Go through the directory structure in this Directory Structure of EAR/WAR/JAR

Problem is not modifying but rather loading the modified path/file. There is a term called Hot Deployment. You are making that even Hotter LOL !!. Whenever you change a specific file the Application server needs to reload the specific WAR or EAR (in case the files changed are class files or java files). generally JSP and HTML file changes made while the application is running becomes available at the time of reload.

If the specific file is inside a JAR you may have to recompile the jar and redeploy/reload it into your application. This may help Loading jar at runtime/dynamically

Community
  • 1
  • 1
Acewin
  • 1,657
  • 4
  • 17
  • 36