반응형

Framework 73

[Error] Caused by: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'post' available as request attribute

There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/post/createPostForm.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/createPostForm.html]") Caused by: org.attoparser.ParseException: Error dur..

DTO

✨ DTO Data Transfer Object 계층간에 데이터를 전송할 때 사용한다. Contoller와 View, Controller와 Service DTO를 사용하는 이유 내부 데이터 구조를 유출하지 않는다. 유지보수가 쉬워진다. DTO를 사용하는 흐름 View에서 Contoller로부터 DTO를 받는다. Contoller에서 Service로 DTO를 보낸다. Service에서 Entity를 Controller에 보낸다. Controller에서 Entity를 DTO로 변환하고, model에 담아 View로 보낸다. DTO ➡️ Entity 또는 Entity ➡️ DTO로 변환하기 [첫 번째 방법] ModelMapper 사용 ModelMapper를 사용하면 자동으로 해줘서 편하다. [두 번째 방법] ..

[Error] Error creating bean with name 'emailConfig': Injection of autowired dependencies failed;

🎀 해결 이메일 서비스 테스트에서 생긴 에러 에러 로그를 자세히 보니 Jasypt 비밀번호 문제였다. 테스트할 sendMessage에 VM Option을 줬다. 🐝 에러 로그 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: either 'jasypt.encryptor.password', one of ['jasypt.encryptor.private-key-string', 'jasypt.encryptor...

JavaMailSender를 이용한 메일 전송

메일로 임시 비밀번호를 전송하는 것을 구현해보았다. implementation 'org.springframework.boot:spring-boot-starter-mail' build.gradle의 dependencies에 추가 spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username=발송할이메일 spring.mail.password=비밀번호 spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true// TLS-protected 연결 허용 application-mail.properties를 생성한 후 위의 내용을 추가했..

[Error] Error creating bean with name 'emailConfig': Injection of autowired dependencies failed;

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.mail.username' in value "${spring.mail.username}" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(A..

redirect

클라이언트가 서버로 요청함 서버가 다른 URL로 리다이렉트함 클라이언트가 바뀐 URL로 다시 서버에 요청 👇 참고 https://webstone.tistory.com/65 리다이렉트란(Redirect) HTTP 리다이렉트(Redirect)란? 리다이렉트란 말 그대로 re(다시) + 지시하다(direct) 다시 지시하는 것을 말한다. 예를 들어 브라우저가 www.webstone.com/blogA URL을 웹 서버에 요청했다고 하.. webstone.tistory.com

@RequestParam | @PathVariable | @RequestBody | @ModelAttribute

@RequestParam 사용 예시 @PostMapping("/user/phoneCheck") // 전화번호 중복 검사 @ResponseBody public boolean phoneCheck(@RequestParam("phone") String phone){ LOG.info("userPhoneCheck 진입"); LOG.info("전달받은 번호:"+phone); boolean flag=userService.userPhoneCheck(phone); LOG.info("확인 결과:"+flag); return flag; } /user/phoneCheck?phone=01012345678 프런트엔드에서 name과 RequestParam 변수명이 같아야 함 @RequestParam Map params Map 타입으로..

개인정보 수정

@GetMapping("/user/form") // 개인정보 수정 public String updateForm(Model model){ Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String id=authentication.getName(); // 로그인한 유저 id model.addAttribute("user", userService.findByUsername(id).get()); return "/user/updateForm"; } 유저 아이디를 이용해서 객체를 찾아 model에 담았다. 개인정보수정 개인정보수정 버튼은 사용자가 로그인했을 때 보인다. 참고 👇 https://flyburi...

@DataJpaTest와 @SpringBootTest

@DataJpaTest @SpringBootTest JPA 테스트와 연관된 config만 적용 full application config를 로드 자동으로 롤백 수동 롤백 in-memory DB를 이용해 테스트 @Component 빈은 @SpringBootTest를 쓰자. 참고 👇 https://krksap.tistory.com/1013 @SpringBootTest와 @DataJpaTest 차이점 @SpringBootTest와 @DataJpaTest 차이점 Spring Application(스프링 어플리케이션)은 ApplicationContext이다. 스프링의 기본 컨셉이 ApplicationContext에 Bean(Object)들을 미리 로드 해놓고 사용하는 컨셉이기.. krksap.tistory.com..

반응형