1.데이터베이스, 사용자, 권한 생성
create user 'cos'@'%' identified by 'cos1234';
GRANT ALL PRIVILEGES ON *.* TO 'cos'@'%';
create database security;
use security;
2.SpringBoot 프로젝트 생성
2.Application 파일 설정 변경
server:
port: 8080
servlet:
context-path: /
encoding:
charset: UTF-8
enabled: true
force: true
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/security?serverTimezone=Asia/Seoul
username: cos
password: cos1234
mvc:
view:
prefix: /templates/
suffix: .mustache
jpa:
hibernate:
ddl-auto: update #create 시작할 때 마다 DB 초기화, update 시작할 때 마다 DB 초기화하지 않음, none
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
show-sql: true
3.Contrroller 생성 ㄱㄱ
@Controller
public class IndexController {
// localhost:8080
// localhost:8080/
@GetMapping({"","/"})
public String index() {
return "index";
}
}
4.View 화면 생성 ㄱㄱ
5.Web 설정 ㄱㄱ
package com.goodbam.security1.config;
import org.springframework.boot.web.servlet.view.MustacheViewResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer{
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setCharset("UTF-8"); // 인코딩
resolver.setContentType("text/html; charset=UTF-8");
resolver.setPrefix("classpath:/templates/"); // 폴더
resolver.setSuffix(".html"); // 확장자 이름
registry.viewResolver(resolver);
}
}
6.프로젝트 실행
-끝-
'Spring Boot > Security' 카테고리의 다른 글
[SpringBoot Secyruty] 구글 로그인 (2) (0) | 2022.04.24 |
---|---|
[SpringBoot Secyruty] 구글 로그인 (1) (0) | 2022.04.23 |
[SpringBoot Secyruty] 권한 처리 (0) | 2022.04.22 |
[SpringBoot Security] 로그인 페이지 만들기 (0) | 2022.04.22 |
[SpringBoot Secyruty] 회원가입 페이지 만들기 (0) | 2022.04.20 |