thymeleaf-spring
thymeleaf-spring copied to clipboard
templateEngine cause spring boot shutting down
thymeleaf 3.0.1 spring boot: 2.1.3
i was use thymeleaf templateEngine to create static html file when user visit the page。
when i depoly to tomcat, found that when create some html file, the spring boot site will be shutting down and restart。
code like this:
ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
resolver.setPrefix("templates/");
resolver.setSuffix(".html");
TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(resolver);
Context context = new Context();
context.setVariables(mode.asMap());
FileWriter writer = new FileWriter(saveFilePath);
templateEngine.process(templateName, context, writer);
log like :
19:59:17.916 | INFO | Shutting down ExecutorService 'applicationTaskExecutor' | ThreadPoolTaskExecutor.shutdown(208) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:17.917 | INFO | DatebookHikariCP - Shutdown initiated... | HikariDataSource.close(350) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:17.928 | INFO | DatebookHikariCP - Shutdown completed. | HikariDataSource.close(352) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:20.969 | INFO | Starting ZxtSiteApplication on 10-79-15-173 with PID 22332 (/home/zskd_zxtsch_site/tomcat-8.0.30/webapps/zskd_zxtsch_site/WEB-INF/classes started by zskd_zxtsch_site in /home/zskd_zxtsch_site) | ZxtSiteApplication.logStarting(50) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:20.986 | INFO | No active profile set, falling back to default profiles: default | ZxtSiteApplication.logStartupProfileInfo(675) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:22.289 | INFO | Root WebApplicationContext: initialization completed in 1233 ms | ContextLoader.prepareWebApplicationContext(296) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:23.629 | INFO | Initializing ExecutorService 'applicationTaskExecutor' | ThreadPoolTaskExecutor.initialize(171) | ContainerBackgroundProcessor[StandardEngine[Catalina]] |
19:59:23.859 | INFO | Adding welcome page: class path resource [public/index.html] | WelcomePageHandlerMapping.