본문 바로가기

개발

(23)
ModelMapper 사용 ModelMapper를 사용하니 Entity-DTO 전환이 한층 수월해졌다. 기존엔 생성자 혹은 builder를 사용하여 Entity-DTO 전환을 하였다. public class QnaRequestDto { private String title; private String content; public QnaRequestDto(Qna qna) { this.title = qna.getTitle(); this.content = qna.getContent(); } public static Qna toQna(QnaRequestDto qnaRequestDto) { return Qna.builder() .title(qnaRequestDto.getTitle()) .content(qnaRequestDto.getCont..
스프링 Paging 및 Parameters public Page getFeedResponses(@RequestParam("page") int page, @RequestParam("size") int size, @RequestParam("sortBy") String sortBy, @RequestParam("isAsc") boolean isAsc) { page = page - 1; return feedService.getFeeds(page, size, sortBy, isAsc); 보통은 paging 할 때, 저렇게 파라미터를 다 전달한 다음, Sort.Direction direction = isAsc ? Sort.Direction.ASC : Sort.Direction.DESC; Sort sort = Sort.by(direction, sortBy); ..
Page<Entity>에서 Page<DTO>로 전환 https://spring.io/guides/tutorials/rest/ Building REST services with Spring this tutorial is designed to be completed in 2-3 hours, it provides deeper, in-context explorations of enterprise application development topics, leaving you ready to implement real-world solutions. spring.io Rest API의 HATEOAS를 구현하기 중에 Page를 return 하니, 아이디와 비밀번호가 다 노출되는 상황이 발생했다. Page qna = qnaService.getQnaAll(pageable)..
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method fail.. 컴파일 하는 데 다음과 같은 에러가 떴다. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate Sess..
application-local/dev/prod.properties 개발을 할 때 환경에 따라 application.properties를 수정해줘야 할 때가 있다. 배포는 배포에 맞게, 로컬은 로컬에 맞게. 이렇게 설정하면 된다. application-.properties 원래 있던 application.properties 파일은 놔두고 하나 더 생성한 한다. 파일명은 에 dev, local, prod, test 등 맞게 설정하면 된다. dev - 개발 local - 로컬 prod - 배포 test - 테스트. 아무렇게나 지어도 되지만, 보통 저 컨벤션을 따른다. 예시 application-prod.properties 그리고 나서 원래 application.properties 파일로 간다. 그리고 안에 내용을 다 지운다. spring.profiles.active= 혹은 ..
자바 완전 정복 필기 "클래에서 객체를 만드는 과정은 생성자가 수행한다." A a = new A(); 'A() 생성자로 만든 객체를 힙 메모리에 넣고, 위칫값을 A 타입의 참조 변수a에 저장하라!'
React.js, 스프링 부트, AWS로 배우는 웹 개발 101 필기 스프링 프레임 워크의 핵심 의존성 주입 "의존성 주입은 디자인 패턴으로 IoC를 구현하는 방법 중 하나."
Encoded password does not look like BCrypt http://www.yes24.com/Product/Goods/103453774 스프링 부트 쇼핑몰 프로젝트 with JPA - YES24 스프링 부트와 JPA를 활용하여 실제 이커머스 업계에서 활용되는 쇼핑몰 기술들을 직접 구현해볼 수 있게 구성하였다. JPA와 Thymeleaf에 대한 간단한 예제로 기본 개념과 사용법을 익히고 그 후 쇼 www.yes24.com 이 책에서 나온 로그인 기능을 구현 하는데, 갑자기 Encoded password does not look like BCrypt 이 에러가 떴다. https://www.codejava.net/frameworks/spring/encoded-password-does-not-look-like-bcrypt [Fixed] Spring Security:..
AWS EB, ECR과 도커를 활용한 배포 yml 파일을 수정한다. name: Build and Push Docker Image on: push: branches: - main jobs: build-and-push-image: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle run: ./gradlew clean build -x test # run: gradle build..
AWS CloudFront HTTP-HTTPS Redirection SSL 인증서를 CloudFront에 다 달아도 막상 웹사이트에 www.heartmuscle.shop을 쳐서 접속하면 https가 아닌 http로 접속 되고, https는 직접 앞에 쳐줘야지 https로 접속이 되었다. 검색 결과 cloudfront에서 redirect를 설정 해주면 된다고 한다. CloudFront에서 해당 "distribution"을 클릭 한 후 "behaviors"로 들어간다. 해당 distribution을 클릭 후 편집에 들어가면, 밑에 보면 아래와 같이 "Viewer protocol policy"가 있다. 기본이 "HTTP and HTTPS"로 되어 있을텐데 이걸 "Redirect HTTP to HTTPS"로 바꿔주면 된다. 그럼 이제 앞에 https를 직접 쓰지 않아도 http..