@Test @DisplayName("templateResolverのBeanが定義されている") public void templateResolverTest() { Method templateResolverMethod = assertDoesNotThrow(() -> MvcConfig.class.getMethod("templateResolver")); Bean bean = templateResolverMethod.getAnnotation(Bean.class); assertNotNull(bean); SpringResourceTemplateResolver templateResolver = mvcConfig.templateResolver(); assertAll("templateResolver not configured correctly", () -> assertEquals("classpath:/templates/", templateResolver.getPrefix()), () -> assertEquals(".html", templateResolver.getSuffix()), () -> assertEquals(TemplateMode.HTML, templateResolver.getTemplateMode()), () -> assertEquals(StandardCharsets.UTF_8.name(), templateResolver.getCharacterEncoding()), () -> assertEquals(false, templateResolver.isCacheable()) ); }
@Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); templateResolver.setCacheable(false); return templateResolver; }
MvcConfig { @Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); templateResolver.setCacheable(false); return templateResolver; } }
MvcConfig { @Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); templateResolver.setCacheable(false); return templateResolver; }  }
MvcConfig { @Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); templateResolver.setCacheable(false); return templateResolver; }  @Bean SpringResourceTemplateResolver templateResolver(); @Bean SpringTemplateEngine templateEngine(SpringResourceTemplateResolver templateResolver); @Bean ThymeleafViewResolver viewResolver(SpringTemplateEngine templateEngine); @Bean MessageSource messageSource(); }
MvcConfig { @Bean public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); templateResolver.setCacheable(false); return templateResolver; }  @Bean SpringResourceTemplateResolver templateResolver(); @Bean SpringTemplateEngine templateEngine(SpringResourceTemplateResolver templateResolver); @Bean ThymeleafViewResolver viewResolver(SpringTemplateEngine templateEngine); @Bean MessageSource messageSource();  }