문제해결(15)
-
[SpringBoot] SpringBoot H2 데이터베이스 설정
1. 의존성 추가 gradle dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.projectlombok:lombok:1.18.24' runtimeOnly 'com.h2database:h2' } 2. h2 데이터베이스 설정 application.yml에 "local", "dev" 프로파일 그룹을 생성한 다음 "testdb" 프로파일에 h2 데이터베이스 설정을 하겠습니다. spring: profiles: group: "local": "testdb" "d..
2022.11.21 -
[thymeleaf][springboot] img 태그의 src url 설정
이미지 소스 위치 resources/static/images/member/ic_my_menu_1 img 태그 src 값 설정
2022.11.15 -
[SpringBoot] @TestPropertySource 애노테이션 사용시 yml 파일의 프로퍼티 불러오기
@TestPropertySource 애노테이션의 yml 파일에 저장된 프로퍼티 불러오기 @TestPropertySource 애노테이션의 locations 옵션을 사용하면 파일에 설정된 프로퍼티 속성을 불러올 수 있습니다. 그런데 locations 옵션 설명을 보면 지원하는 파일 형식은 *.properties 형식이나 *.xml 형식만을 지원합니다. 예를 들어 properties 형식의 파일을 불러온다고 가정하면 다음과 같이 정의할 수 있습니다. @SpringBootTest @TestPropertySource(locations = {"classpath:/application.properties"}) public class SpringBootApplicationTest { 하지만 yml 파일 같은 경우 다음..
2022.10.31 -
[SpringBoot] 회원가입 서비스의 패스워드 암호화
개요 SpringBoot 기반으로 회원가입 서비스를 구현중 회원가입을 수행하면 데이터베이스에 패스워드 값이 그대로 노출되어 저장됩니다. 이 문제를 해결하기 위해서 데이터베이스에 저장하기 전에 패스워드를 암호화를 수행합니다. 의존성 추가 implementation 'org.springframework.boot:spring-boot-starter-security' SecurityConfig 클래스 정의 아래 코드에서 주목할 점은 빈으로 passwordEncoder를 설정한 점입니다. 빈으로 설정하였기 때문에 주입이 필요한 경우 @Autowired를 통해서 주입할 수 있습니다. @EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilt..
2022.09.09 -
[SpringBoot] input 태그 date 타입을 LocalDate 타입으로 매핑하기
개요 SpringBoot 기반으로 회원가입 서비스를 구현중 회원의 생년월일을 입력받아 저장합니다. createMemberForm.html ... 생년월일 ... 위와 같이 생년월일 입력 필드가 있다고 가정합니다. MemberForm 클래스 @Getter @Setter public class MemberForm { ... @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate birthday; ... } MemberForm 클래스의 birthday 필드 멤버 타입은 java.time.LocalDate 클래스입니다. @DateTimeFormat 어노테이션을 이용하여 입력받은 날짜 형식을 "yyyy-MM-dd" 형식으로 입력받습니다. References sour..
2022.09.07 -
[SpringBoot] 회원가입 비밀번호, 비밀번호 확인 불일치 처리
개요 SpringBoot 기반 회원가입 서비스 구현중 비밀번호, 비밀번호 확인 필드 입력이 불일치하는 경우 "비밀번호가 일치하지 않습니다." 메시지를 출력하고자 합니다. 이 글은 이전 문제해결 글을 기반으로 해결한 문제이기 때문에 글에서 생략된 부분이 많습니다. https://yonghwankim-dev.tistory.com/515 [SpringBoot] 회원가입 유효성 검증 및 중복 조회 처리 개요 SpringBoot 기반으로 회원가입 서비스를 구현하던 중 사용자로부터 입력받은 회원가입 입력정보들이 올바른지 유효성을 검증하고 만약 이미 가입된 아이디, 이메일, 연락처 정보가 있다면 이 yonghwankim-dev.tistory.com CheckPasswordEqualValidator 클래스 추가 @Re..
2022.09.07