Spring 24

비밀번호 암호화 적용하기(Spring Security Crypto)

https://20240228.tistory.com/153 비밀번호 암호화목차암호화 종류단방향 암호화 방법단방향 암호화 문제점 개선 (+ Salt)단방향 암호화 문제점 개선 (+ Key Stretching)양방향 암호화 특징 참고 자료암호화 종류 암호화를 하는 이유는 해당20240228.tistory.com 최근에 비밀번호 암호화에 대해서 공부했었다. 그중에 단방향 암호화 라이브러리인 Spring Security Crypto를 사용해서 프로젝트에 적용해 보겠다.  라이브러리 Dependency 찾기 Maven Repository : Spring Security Crypto 검색   build.gradle  특정 버전 명시 Odependencies { implementation group: 'org.spr..

JWT를 이용한 인증

JWT 공식 홈페이지 JWT.IOJSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.jwt.ioJWT 자바 라이브러리(jjwt-root) GitHub - jwtk/jjwt: Java JWT: JSON Web Token for Java and AndroidJava JWT: JSON Web Token for Java and Android. Contribute to jwtk/jjwt development by creating an account on GitHub.github.comInpa Dev JWT 토큰 인증 이란? (쿠키 vs 세션 vs 토큰)  🌐..

스프링 부트 프로젝트 빌드

빌드하는 방법프로젝트 루트 경로에서./gradlew build   ./gradlew clean build  clean build vs build 차이점 gradlewGradle Wrapper의 약자로, Gradle Wrapper 스크립트를 실행하는 것프로젝트에 Gradle이 설치되어 있지 않더라도 Gradle Wrapper를 사용하면 해당 프로젝트에 설정된 Gradle 버전으로 빌드를 수행할 수 있다../는 현재 디렉토리에 있는 gradlew 스크립트를 실행하라는 의미 cleanclean 태스크는 빌드 디렉토리를 삭제하는 역할을 한다. 보통 프로젝트의 루트 디렉토리에 build/라는 이름의 디렉토리가 생성되며, 이 디렉토리 안에 모든 빌드 산출물이 저장된다.clean 명령을 실행하면 build/ 디렉토리..

Spring/Spring Boot 2024.08.24

Spring REST Docs 기본 설정

참고 문서 https://docs.spring.io/spring-restdocs/docs/current/reference/htmlsingle/ Spring REST DocsDocument RESTful services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test or WebTestClient.docs.spring.ioSpring REST Docs?Spring Rest Docs는 Spring 애플리케이션에서 RESTful API를 문서화하기 위한 도구API 문서를 수동으로 작성하는 대신, Spring Rest Docs는 테스트 기반으로 문서를 자동 생성API 테스트를 작성하면..

[JPA] 수정은 어떻게 하는 게 좋을까?

여기 블로그 글 엔티티가 있다. @Entity@Getter@NoArgsConstructor(access = AccessLevel.PROTECTED)public class Post { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; @Lob private String content; @Builder public Post(String title, String content) { this.title = title; this.content = content; }} 해당 엔티티의 수정에 대한 방식과 각 방식의 장단점을 정리해 ..

Spring/Spring Data 2024.08.20

[JPA] Pageable 페이징 관련 정리

Pageableorg.springframework.data.domain인터페이스이다. 구현체로는 PageRequest, Unpaged 존재 @GetMapping("/posts")public List getList(@PageableDefault Pageable pageable){ return postService.getList(pageable);}클라이언트가 해당 경로(/posts)로 요청을 보내면 설정에 맞게 Pageable 객체를 만들어서 넘겨준다. 페이지 번호는 0부터 시작  YAML 설정 spring: data: web: pageable: one-indexed-parameters: true # 페이지 1부터 시작 default-page-size: 5s..

Spring/Spring Data 2024.08.19

Spring Jpa 쿼리 로그 yaml 설정

spring: jpa: hibernate: ddl-auto: create show-sql: true properties: hibernate: format_sql: true # SQL 보기 좋게 포맷팅 use_sql_comments: true # SQL 내부에 /* */ JPQL 주석 추가logging: level: org.hibernate:SQL: debug # SQL 쿼리 로그 출력 org.hibernate.type.descriptor.sql.BasicBinder: trace # 바인딩된 매개변수 로그 출력  Spring Boot 3.0 이상 사용 시 JPA 쿼리 parameter 로그 설정logging: level: ..

Spring/Spring Data 2024.08.19

로컬 인메모리 H2 데이터베이스 yaml 설정

application.yaml spring: h2: console: enabled: true path: /h2-console datasource: url: jdbc:h2:mem:jeulog username: sa password: driver-class-name: org.h2.Driver spring.h2.console.enabledH2 데이터베이스의 웹 콘솔을 활성화웹 콘솔을 통해 브라우저에서 데이터베이스를 관리하고, SQL 쿼리를 실행 가능 spring.h2.console.pathH2 콘솔에 접근할 수 있는 URL 경로를 지정http://localhost:8080/h2-console로 접속 spring.datasource.urljdbc:h2:mem : ..

Spring/Spring Data 2024.08.19