29,700원
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
No message found under code 'greeting.message' for locale 'null'. 이랑 한글깨짐
진짜 수업이랑 똑같이 따라갔는데 { "timestamp": "2022-11-30T22:35:23.776+00:00", "message": "No message found under code 'greeting.message' for locale 'null'.", "details": "uri=/hello-world-internationalized" }처음엔 이렇게 오류가 뜨길래 구글링해서@Bean(name="messageSource") public ResourceBundleMessageSource bundleMessageSource() { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasename("messages"); return messageSource; } 이 빈 옵션을 추가하고 나니까 해결이 되었어요..리소스번들이 문제였던거같은데강의 영상에서는 properties파일들이알아서 리소스 번들로 묶이던데 저는 ide를 vscode로 써서 그런가 그렇게 되지가 않아서 이런 오류가 뜬건가요,,?혹시 위에 오류가 떴었던 이유를 알 수 있을까요,,? 이해가 안가서ㅠㅠ그런데 프랑스어랑 영어는 헤더에서 value바꾸니까 정상적으로 작동했는데 안녕하세요만 깨져서 저렇게 나오네요..한글이 다 저런가 싶어서 user예제에 아이디 1,2,3초기화 시켜둔 name을 한글로 바꿔봤는데 그건 또 안깨지고 잘 나오더라구요..
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
PUT과 PATCH의 개념
영한님의 Http 강의에서는PUT은 서버의 리소스를 통째로 덮어쓰기하는 개념이어서 실무에서 사용될 일이 별로 없는 메서드라고 하셨고,PATCH는 리소스의 일부를 수정하는 개념이라고 하셨는데,도원님께서는 PUT을 수정의 개념으로 말씀하셔서 혼란스럽습니다.그리고 PATCH가 어디서 지원이 안 된다고 하셨었는데, 이에 대해서도 구체적으로 알고 싶습니다.조금 민감한 질문일 수 있겠지만, 무엇을 근거로 그렇게 설명해주신 건지 또 왜 그런 건지 궁금합니다. 다음 사이트에서 얘기하는 개념이 영한님께서 말씀해주신 개념과 동일하네요.https://restfulapi.net/http-methods/
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
data.sql 자동 저장이 되지 않습니다
자동 저장이 되지 않아 계속 수동으로 INSERT를 해주었는데요.수동으로 잘 수행이 됐으니 INSERT 문에는 문제가 없을 것 같고(세미콜론도 넣었습니다.),yml 파일의 설정이 뭔가 잘못된 걸까요?의심가는 부분이 있으실지요?스프링부트 버전은 2.5.5입니다.H2도 mem.testdb가 잘 되지 않아 이렇게 저렇게 해보다가 설정파일은 다음과 같이 되었습니다. spring: application: name: catalog-service messages: basename: messages # JPA jpa: hibernate: ddl-auto: create-drop show-sql: true generate-ddl: true defer-datasource-initialization: true # h2: # console: # enabled: true # settings: # web-allow-others: true # path: /h2-console datasource: # url: jdbc:h2:tcp://localhost:8082/~/testdb url: jdbc:h2:~/testdb username: sa password: driver-class-name: org.h2.Driver
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@Bean 어노테이션 지정시 오류
안녕하세요 현재 [다국어 처리를 위한 Internationalization 구현] 강의를 수강하고 있습니다. @SpringBootApplication 어노테이션이 있는 RestfulWebServiceApplication 클래스에서 localeResolver() 메소드에 @Bean 어노테이션을 지정하면 하단의 오류가 출력되는데 어디가 문제인지 도저히 모르겠습니다.. at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96.localeResolver(<generated>) ~[classes/:na] at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication.localeResolver(RestfulWebServiceTutorialApplication.java:22) ~[classes/:na] at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96.CGLIB$localeResolver$0(<generated>) ~[classes/:na] at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96$$FastClassBySpringCGLIB$$5b79685e.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.23.jar:5.3.23] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.23.jar:5.3.23]
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
UserV2에 제대로 접근하지 못합니다.
UserV2 클래스를 만들어 필터링을 적용하려 하는데 아래와 같은 오류로 접근이 불가능합니다.소스도 함께 작성합니다. 왜이런건지 알수 있을까요?2022-11-03 16:28:12.853 WARN 30800 --- [nio-8088-exec-8] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No filter configured with id 'UserInfoV1' (type java.lang.String); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No filter configured with id 'UserInfoV1' (type java.lang.String)] #User.javapackage com.example.restfulwebservice.user; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import net.minidev.json.annotate.JsonIgnore; import javax.validation.constraints.Past; import javax.validation.constraints.Size; import java.util.Date; @Data //lombok 사용으로 생성자,setter,getter 자동으로 생성됨 @AllArgsConstructor //@JsonIgnoreProperties(value={"password","ssn"}) //숨길 데이터를 제어하기 위한 어노테이션 @JsonFilter("UserInfoV1") //Userinfo 라는 정보는 controler , service 에서 사용 가능하게됨 @NoArgsConstructor //디폴트생성자 생성 public class User { private Integer id; @Size(min =2, message = "Name은 2글자 이상 입력해 주세요.") private String name; @Past private Date joinDate; // @JsonIgnore private String password; //@JsonIgnore private String ssn; }#UserV2.javapackage com.example.restfulwebservice.user; import com.fasterxml.jackson.annotation.JsonFilter; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @AllArgsConstructor @Data //lombok 사용으로 생성자,setter,getter 자동으로 생성됨 @NoArgsConstructor @JsonFilter("UserInfoV2") //Userinfo 라는 정보는 controler , service 에서 사용 가능하게됨 class UserV2 extends User{ private String grade; } #AdminUserController.javapackage com.example.restfulwebservice.user; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import org.springframework.beans.BeanUtils; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.json.MappingJacksonValue; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import javax.validation.Valid; import java.net.URI; import java.util.List; @RestController @RequestMapping("/admin") //공통적인 앞의 prefix가 붙는다면 클래스단에 선언하여 적용 가능 public class AdminUserController { private UserDaoService service; public AdminUserController(UserDaoService service){ this.service = service; } @GetMapping("/users") public MappingJacksonValue retrieveAllUsers(){ List<User> users = service.findAll(); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("id","name","joinDate","password"); FilterProvider filters = new SimpleFilterProvider().addFilter("UserInfo",filter); MappingJacksonValue mapping = new MappingJacksonValue(users); mapping.setFilters(filters); return mapping; } //GET /admin/users/1 or /users/9 -> String으로 전달됨 //-> /admin/v1/users/1 //@GetMapping("/v1/users/{id}") //uri를 이용한 버전관리 //@GetMapping(value = "/users/{id}",params = "version=1") //Requst Param으로 관리하느방법 //@GetMapping(value ="/users/{id}",headers = "X-API-VERSION=1") @GetMapping(value ="/users/{id}",produces = "application/vnd.company.appv1+json")//mimetime을 이용하는 방법 public MappingJacksonValue retrieveUserV1(@PathVariable int id){ //int로 자동으로 변환됨 User user = service.findOne(id); if (user == null){ throw new UserNotFoundException(String.format("ID[%s] not found",id)); } SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("id","name","joinDate","ssn","password","grade"); FilterProvider filters = new SimpleFilterProvider().addFilter("UserInfoV1",filter); MappingJacksonValue mapping = new MappingJacksonValue(user); mapping.setFilters(filters); return mapping; } //@GetMapping("/v2/users/{id}") //uri를 이용한 버전관리 //@GetMapping(value = "/users/{id}",params = "version=2") //Requst Param으로 관리하느방법 //@GetMapping(value ="/users/{id}",headers = "X-API-VERSION=2") //header 값으로 관리하는 방법 @GetMapping(value ="/users/{id}",produces = "application/vnd.company.appv2+json") // public MappingJacksonValue retrieveUserV2(@PathVariable int id){ //int로 자동으로 변환됨 User user = service.findOne(id); if (user == null){ throw new UserNotFoundException(String.format("ID[%s] not found",id)); } // User -> User2 UserV2 userV2 = new UserV2(); BeanUtils.copyProperties(user,userV2); userV2.setGrade("VIP"); SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("id","name","ssn","grade"); FilterProvider filters = new SimpleFilterProvider().addFilter("UserInfoV2",filter); MappingJacksonValue mapping = new MappingJacksonValue(user); mapping.setFilters(filters); return mapping; } }
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@JsonIgnore 어노테이션 적용이 안됩니다..
질문처럼 강의에서나온 @JsonIgnore 어노테이션 적용이 되지않고 PostMan 에서 그대로 필드가 노출되는 현상입니다.왜 적용이 안되는지 알수 있을까요 서버도 재기동 한 상태입니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@ExceptionHandler(MethodArgumentNotValidException.class) 예외 response 메서드 파라미터 관련하여 질문있습니다.
안녕하세요.유효성 체크를 위한 Validation API 사용 강의를 듣고 의문이 생겨 질문드립니다.ResponseEntityExceptionHandler 클래스에 http 예외 response 메서드가 정의되어있다고 하셨고, 이를 오버라이딩하여 사용했을 때는@Override protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { ExceptionResponse exceptionResponse=ExceptionResponse.builder() .timestamp(new Date()) .messsage(ex.getMessage()) .details(ex.getBindingResult().toString()) .build(); return ResponseEntity.status(status).body(exceptionResponse); } 의도한대로 exceptionResponse가 http body에 들어갔습니다. 제가 여기서 ResponseEntityExceptionHandler 클래스를 상속받지 않고, @ExceptionHanlder(MethodArgumentNotValidException.class)를 통해 에러를 캐치하고자 하였는데요.@Override protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { ExceptionResponse exceptionResponse=ExceptionResponse.builder() .timestamp(new Date()) .messsage("Validation Failed") .details(ex.getBindingResult().toString()) .build(); return ResponseEntity.status(status).body(exceptionResponse); } 이때는 저희가 작성한 exceptionResponse가 http body에 담기지 않는 것을 확인할 수 있었습니다.그래서 앞서 작성한 메서드(MethodArgumentNotValidException.class만 캐치하는 메서드)를 삭제하였을 때는 @ExceptionHandler(Exception.class) public final ResponseEntity<Object>handleAllExceptions(Exception ex, WebRequest request){ ExceptionResponse exceptionResponse=ExceptionResponse.builder() .timestamp(new Date()) .messsage(ex.getMessage()) .build(); return ResponseEntity.status(HttpStatus.NOT_FOUND) .body(exceptionResponse); } 전체 에러를 잡는 메서드가 따로 있기 때문에 커스텀한 에러 메시지가 응답되었습니다. 여기서 제가 내린 결론은 @ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { ExceptionResponse exceptionResponse=ExceptionResponse.builder() .timestamp(new Date()) .messsage("Validation Failed") .details(ex.getBindingResult().toString()) .build(); return ResponseEntity.status(status).body(exceptionResponse); } 해당 메서드가 MethodArgumentNotValidException.class 에러를 캐치하지만 로직을 수행하고 있지 못하다. 입니다. 그래서 다음과 같이 파라미터를 바꾸어줬더니@ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex) { ExceptionResponse exceptionResponse=ExceptionResponse.builder() .timestamp(new Date()) .messsage("Validation Failed") .details(ex.getBindingResult().toString()) .build(); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exceptionResponse); } 에러를 캐치하고 Custom한 ResponseException을 전달받았습니다. 그럼 이러한 에러를 캐치하고 custom한 responseException을 만들 때 메서드의 파라미터는 어떻게 정해야 하는 건가요???? 또한, 제가 생각한 이 과정이 맞는지 궁금합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
userV2 클래스에서 @Data 에러 발생시 참고
스프링부트 2.7.3 사용 중입니다.UserV2 클래스가 User 클래스를 상속하도록 코드를 수정하면 @Data annocation에서 에러가 발생합니다."Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '(callSuper=false)' to your type."에러 메시지의 가이드대로 UserV2 클래스에 "@EqualsAndHashCode(callSuper = false)"를 추가하면 @Data에서 발생하는 에러가 사라집니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
한글이 물음표로 표시되는 경우 참고
M1 맥 사용 중입니다.9:25 에서 locale 미지정 상태에서 body가 "?????"로 출력되어 이것저것 찾아보면서 바꿔보았는데, 결국에는 제가 생성한 messages.properties 파일의 인코딩 문제였습니다.아래 블로그 참고하셔서 properties 파일의 인코딩을 UTF-8로 변경하시면 해결됩니다.해당 값이 default로 설정되어 있으면 messages.properties 파일을 reopen 했을 때 "안녕하세요"가 "?????"로 표기되어 있을 수 있습니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
delete 복수 데이터는 어떻게 하나요?
설명해 주신대로 delete /users/{id} 를 사용하면 하나의 유저는 삭제가 되겠지만 복수개의 데이터를 삭제하려고 하면 어떤 식으로 설계 해야 할까요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
질문드립니다
포스트맨 실행시 사용자 추가기능에서 Send 하면 정상적으로 201Created는 나오는데 Location에서 URI 에 정상적인 아이디 생성이 안되는데 어떤 문제인지 여쭤봐도 될까요??전체조회를 하면 아이디는 나오긴 합니다,,,[ 사용자 추가 후 전체조회 ]
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@JosnIgnore
안녕하세요 강의 잘 듣구 있습니다.@JsonIgnore 에 대해서 질문이 있습니다.해당 어노테이션을 사용하면 클라이언트가 못보는 것 뿐이고 해당 도메인이 controller 나 dao 를 탈 때 여전히 값이 같이 넘어가는것으로 아는데, 현업에서 @JsonIgnore 을 그대로 필드에 이와같이 사용하는지, 아니면, 따로 Dto를 생성해서 전송하는지 궁금합니다.감사합니다.
- 해결됨[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
UserNotFoundException
UserNotFoundException 에서 질문.UserNotFoundException 라는 클래스에서 UserNotFoundException메서드는 생성자로 알고 있는데 어떻게 String message 를 파라미터로 받을 수 있는지 궁금합니다.private String message; 필드가 있어야 받아서 생성자를 만들 수 있지 않나요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
질문드립니다.
어떻게 @Valid 실패 시 저희가 오버라이딩 한 handleMethodArgumentNotValid 예외가 발생하는지 궁금합니다. 그냥 원래 @Valid 실패시 BindingResult 로 받지 않는 이상 handleMethodArgumentNotValid 예외가 발생하는 것으로 이해하면 될까요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@RequestBody String name
이렇게 바꿔보았습니다. 해당 요청 시 이렇게 이름이 변경됩니다. 혹시 어디가 잘못 된것일까요? @RequestParam 이 아닌 바디로 요청을 주고싶습니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
PUT 리뷰 부탁 드립니다.
변경할 값이 이름 뿐이라 생각하여 이렇게 작성하였는데, 요청 body에 "name" 필드가 없을 때 예외처리를 하고 싶어, 이렇게 해보았는데 if문에 2개인게 좋지 않다 생각되어 혹시 다른 방법이 있을지 여쭤봅니다. 2. 그리고 @RequestBody String name 으로 받는 것도 바람직한 방법인지 궁금합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@ControllerAdvice에 대해.
@ControllerAdvice을 붙이면 해당 클래스가 컨트롤러가 실행될 때 실행 된다고 하셨는데 이는 맨 처음 스프링이 올라갈 때 componentscan을 통해 컨트롤러가 빈으로 등록 될 때 같이 올라간다는 말씀이신가요? ( @ControllerAdvice 안에 @Component 가 있더라구요.) 2. @ControllerAdvice 을 붙이면 컨트롤러에서 터진 예외만 핸들링 할 수 있는 건가요? 이름 때문에 헷갈리네요. 만약 서비스단이나 엔티티의 비지니스로직에서 핸들링 하고 싶으면 따로 어떻게 처리 해야되는지 궁금합니다. 3. 간단한 질문입니다. @ExceptionHandler 의 파라미터로 지정한 예외가 터지만 해당 메서드가 실행되는데 이 때 파라미터로 Exception, WebRequest 정보가 들어오나요? 관례적으로 이 두가지를 받는지 궁금합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
REST API를 이용한 프로젝트
안녕하세요! 강의 잘 듣고 있습니다. ㅎㅎ 혹시 RESTful API 방식으로 웹 프로젝트를 진행할 수 있을지 궁금합니다. 이전에는 JSP/Servlet방식으로 웹 프로젝트를 진행한 경험이 있는데 REST API를 사용하여 웹프로젝트를 진행할 수 있을까요?? 간단한 게시판이나 정보제공 형식의 웹페이지를 만들고 싶습니다. 제가 입문자라 질문이 이상할 수도 있을 거 같습니다 양해 부탁드립니다!
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
insert 가 안됩니다...
data.sql을 만들고 insert구문을 쓰면 Table "USERALL" not found 에러가 뜹니다 보다싶이 insert 구문을 쓰기 전까지는 테이블이 생성된 걸 h2-console에서 확인할 수 있었습니다 ㅠㅠ 그런데 data.sql만 생성하고 insert하려고 하면 갑자기 테이블이 없다고 뜨네요 .... yml 파일이고 spring: jpa: show-sql: true hibernate: ddl-auto: create defer-datasource-initialization: true messages: basename: messages mvc: pathmatch: matching-strategy: ant_path_matcher #h2 console 활성화 h2: console: enabled: true #원격접속 허용 settings: web-allow-others: true # 경로 path: /h2-console #유일한 이름 생성 여부 datasource: generate-unique-name: false #url 경로 url: jdbc:h2:mem:testdb #class 명칭 driver-class-name: org.h2.Driver pom 파일입니다 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.200</version> <scope>runtime</scope> <!-- RUNTIME 에서만 실행 --></dependency>
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
강의자료
강사님 이번 강의도 잘 듣고 있는 수강생입니다. 혹시 파워포인트 자료가 이제는 공개가 가능한지요?