Spring Boot DevTool
Lombok
Spring Data JPA
MySQL Driver
Spring Security
Mustache
Spring Web
@Controller
public class IndexController {
@GetMapping({"", "/"})
public String index() {
return "index";
}
}
@Controllerreturn "index";는 인덱스 뷰파일을 반환하겠다는 의미.src/main/resources/templates/index.mustachesrc/main/resources/으로 잡힘.application.yml
# 굳이 안 해도 되는 설정. why? -> pom.xml에 머스테치 의존성 등록하면 아래의 경로가 자동으로 잡힘.
mvc:
view:
prefix: /templates/
suffix: .mustache

index.html생성..html@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setCharset("UTF-8"); // 우리가 만든 뷰의 인코딩은 UTF-8
resolver.setContentType("text/html;charset=UTF-8"); // 우리가 주는 파일은 html(UTF-8)
resolver.setPrefix("classpath:/templates/"); // classpath:는 프로젝트 경로.
resolver.setSuffix(".html"); // .html을 만들어도 머스테치로 인식.
registry.viewResolver(resolver); // 매개변수의 레지스터로 뷰리졸버를 등록.
}
}
.html파일을 .mustache파일로 변환.security password가 뜸.

localhost:8080접속 시 자동으로 http://localhost:8080/login으로 이동됨.
시큐리티 의존성을 추가하면 우리가 접속하려는 모든 주소가 막히고 인증이 필요하게 됨.
콘솔창에 있던 비밀번호를 이용해서 로그인을 해주면 됨.



localhost:8080/logout접속.