20%
23,760원
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 해결됨[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
1번 회원 삭제 후, 1번 개별조회는 안되고, DB에는 데이터가 남아있는 현상 질문입니다
관심 가져주셔서 감사합니다.약간의 리팩토링과, 응용을 거쳐 DB처리에 문제가 없도록 했었습니다. UserJpaController.java @RestController@RequestMapping("/jpa")public class UserJpaController { ... @DeleteMapping("/users/{id}") public MappingJacksonValue deleteUser(@PathVariable Integer id) { final User deleteUser = getUserById(id); userRepository.delete(deleteUser); //> here return getMappingJacksonValueByModel( deleteUser, "UserInfo", getFilterByModelFields("name", "joinDate") ); } ...} 설정이 추가된 환경 요소입니다 Window 10 Spring boot 2.5.2 H2: 1.4.197 - Embeded TCP Server @Configurationpublic class H2DatabaseServerConfig { @Bean public Server h2TcpServer() throws SQLException { return Server.createTcpServer( "-tcp", "-tcpDaemon", "-tcpAllowOthers" ).start(); }} 문제 1번 회원 조회 - 정상 출력 회원 1번을 삭제합니다: 그러나, Delete 쿼리가 Log 에 없습니다 1번 회원 재 조회시 없다고 출력됩니다 전체 회원조회를 하면 1번회원이 살아있습니다: 이것은 즉, 전체조회 쿼리는 Log에 남고,Delete 쿼리는 전송되지 않는것 같습니다.-Delete user 요청 후 DB 테이블 DELETE /jpa/users 요청 후 서버 log 입니다: save() .deleteById() & delete() 모두 안됩니다 질문 JPA EntityManager 에서 트렌젝션 처리가( em.flush() ) 안된것으로 추측이 됩니다만, 이부분은 JpaRepository 구현체 에서 자동처리가 되어야 하는것이 아닌가요?- 아래와 같이 Controller 에서 실행해 보았으나, 역시나 쿼리전송이 안되는것 같습니다 userRepository.delete(deleteUser);userRepository.flush(); @Transactional 을 Controller 에 붙여 주는걸로도 해결이 안되는데 혹시 추가해결방법이 있을까요? 서버 메세지 중Did not store anonymous SecurityContext이것이 왜 뜨는것일까요... 인증문제 같습니다.(서버에 예제와 같이 Security 초기 설정을 했습니다): 웹브라우저 상에서 /h2-console 접근은모두 가능합니다.- jdbc:h2:mem:testdb- jdbc:h2:tcp://localhost:9092/mem:testdb 제가 놓치고 있는것에 대해 조언을 구합니다감사합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
JPA 는 무조건 spring 올라올때 table drop하나요?
로그를 보니 스프링 올라올때 jpa는 무조건 테이블 drop하는거 같은데 mysql이나 oracle사용하면 어떻게 대처해야 하나요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
Optional 처리방법 문의
isPresent 와 orElseThrow 의 차이점에 대해 문의 드립니다. Optional 을 공부하다보니 에러처리를 동시에 하는 함수가 있어서 사용해보았습니다. 제가 생각할때는 변수에 저장하지 않고 바로 사용하는 부분이 장점 같았는데, 두 방식에서 내부동작의 차이점이 있는지 궁금합니다. Optional<User> findById = userRepository.findById(id); if (! findById.isPresent()) { throw new UserNotFoundException(id); } userRepository.findById(id).orElseThrow(() -> new UserNotFoundException(id))
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
PK GenerationType 선택기준 질문
@GeneratedValue(strategy = GenerationType.SEQUENCE) @GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.TABLE) JPA에서 지원되는 PK생성 전략을 네가지로 확인했습니다. 찾아보니 DB 에 따라 Oracle 이면 Sequence, MySQL 쪽이면 Identity 를 사용한다는 걸 알게 되었고, Identity 는 현재 생성된 키 값을 기준으로 증가한다는 것을 확인했습니다. 그렇다면 Sequence, Auto 그리고 Table 의 차이점이나 주로 어떻게 사용이 구분되는지 알고 싶습니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
@JsonFilter("UserInfo") 를 사용하면 ResponseEntity<List<User>>를 못쓰나요?
@JsonFilter("UserInfo") 를 사용해서 기존에 개발했던 아래 함수를 호출 하니 에러가 발생합니다. 모델쪽에 JsonFilter를 사용하면 컨트롤러쪽에 MappingJacksonValue는 반듯이 사용해야 하는 건가요? @GetMapping("/users")public ResponseEntity<List<User>> retrieveAllUsers(){
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
messages파일이 여러개 일경우 어떻게 하나요?
application.yml파일어 어떻게 선언하나요?
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
이 강의 어느 부분에 AOP가 적용된건가요?
코드상에 AOP가 안보이는데 어느 부분에 코딩으로 AOP가 적용됐는지 알 수 있을까요?
- 해결됨[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
API란
안녕하세요 선생님! 웹 백엔드 개발자를 희망하는 대학생입니다. 선생님의 강의를 들으며 api를 설계하고 있는데 궁금증이 생겼습니다. 이전 까지 학습했던 spring 기반 웹 공부는 사용자의 요청에 따라 SSR를 통해 view를 응답해주는 것으로 알고 있는데 api는 uri와 http 메소드를 통해 json으로 응답해주는 것으로 알고 있습니다. 궁금한 점은, 프로그래머가 아닌 일반 사용자가 view 에서가 아닌 api를 통해 json 형식으로 회원가입, 조회를 하지 않는거 같은데 api는 언제 쓰이는지 궁금합니다. 단순 개발자의 편의를 위해? 너무 두서가 없네요ㅠㅠ 아직 api의 감이 안잡혀서 그런거같습니다.. 본질적으로 왜 쓰이는지에 대해서 인지를 하고 학습을 하면 더 유용할 것 같습니다. 감사합니다^^
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
h2-console 컬럼순서
- h2-console을 이용해서 실습하는 과정에서 아래 처럼 domain클래스를 생성하여 H2-console로 가서 확인해보면 아래의 순서와 다르게 id빼고는 abcd 알파벳순서대로 컬럼 순서가 정해지네요. 이것을 컨트롤할수 있는 방법은 없나요? id category en kor ..등의 컬럼순서가 아닌 id category detail en ... 알파벳 순서대로 컬럼이 생성됩니다. @Id private String id; private String category; private String en; private String kor; private Integer price; private String location; private String detail;
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
데이터베이스까지 연동.. 질문드립니다!
안녕하세요. 강의 열심히 잘 보고 있는 취업 준비생입니다! 2개 강의에 걸친 스프링 시큐리티 사용법은 yml, config 에 username, password를 따로 명시하는 방법으로 설명해주셨는데요. 그렇다면 데이터베이스의 특정 테이블의 특정 데이터로 매칭하는 방법은 없나요?? 예를 들어 유저가 로그인 할 때는 직접 username과 password를 입력하게 될 텐데 db에 적절한 데이터가 있는 경우에는 그 데이터로 인증을 수행하고, 없는 경우에는 exception을 날리는 식의 프로세스를 생각해보았습니다. 어떤 방법이 있는지 궁금합니다..!
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
Validation이 동작하지 않습니다.
안녕하세요. 강사님 강의 잘 듣고 있습니다. 현재 실습 중 유효성 검사를 할 때 boot에서 유효성 검사가 되지 않습니다. 현재 문제인 부분은 Name에 min=2의 유효 검사를 추가했으나, Name의 길이가 1인 a만 입력해도 추가가 되는 상황입니다. 상태 코드 : 201 pox.xml User.java UserController.java dependancy 리스트
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
swagger-ui.html 404 문제
http://localhost:8088/swagger-ui.html 404 문제 -> http://localhost:8088/swagger-ui/index.html 접속하니 됩니다
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
spring security
java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.of([Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/PluginRegistry; pom.xml에 시큐리티만 추가했을뿐인데 저렇게 에러가 터지네요 현재 스프링부틑 2.4x를 사용중입니다. 스웨거는최신 3.0사용중입니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
HATEOAS질문드립니다
UserControll쪽에 최신으로 올려주신 package com.example.restfulwebservice.user;import org.springframework.data.crossstore.ChangeSetPersister;import org.springframework.hateoas.CollectionModel;import org.springframework.hateoas.EntityModel;import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.*;import org.springframework.web.servlet.support.ServletUriComponentsBuilder;import javax.validation.Valid;import java.net.URI;import java.util.ArrayList;import java.util.List;import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;@RestControllerpublic class UserController { private UserDaoService service; //생성자를 통한 의존성 주입 public UserController(UserDaoService service) { this.service = service; } @GetMapping("/users") public List<User> retrieveAllUsers() { return service.findAll(); } // 전체 사용자 목록 @GetMapping("/users2") public ResponseEntity<CollectionModel<EntityModel<User>>> retrieveUserList2() { List<EntityModel<User>> result = new ArrayList<>(); List<User> users = service.findAll(); for (User user : users) { EntityModel entityModel = EntityModel.of(user); entityModel.add(linkTo(methodOn(this.getClass()).retrieveAllUsers()).withSelfRel()); result.add(entityModel); } return ResponseEntity.ok(CollectionModel.of(result, linkTo(methodOn(this.getClass()).retrieveAllUsers()).withSelfRel())); } //우리는 id를 숫자로 해도 서버측에 전달 될 경우에는 -> String으로 된다 //id로 하면 자동으로 원하는 int에 맞게 찾아준다 //HETAOS를 적용하면 개발자의 양은 많아지지만 //내가 개발한 것을 보는 사용자입장에서는 더 많은 정보를 알 수 있다 // 사용자 상세 정보 @GetMapping("/users/{id}") public ResponseEntity<EntityModel<User>> retrieveUser(@PathVariable int id) { User user = service.findOne(id); if (user == null) { throw new UserNotFoundException("id-" + id); } EntityModel entityModel = EntityModel.of(user); WebMvcLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllUsers()); entityModel.add(linkTo.withRel("all-users")); return ResponseEntity.ok(entityModel); } //post, put 처럼 데이터 맵핑 할려면 파라미터에 request body로 형식을 적어줘야한다 @PostMapping("/users") public ResponseEntity<User> createUser(@Valid @RequestBody User user) { User saveUser = service.save(user); URI localtion = ServletUriComponentsBuilder.fromCurrentRequest() .path("/{id}") .buildAndExpand(saveUser.getID()) .toUri(); return ResponseEntity.created(localtion).build(); } @DeleteMapping("/users/{id}") public void deleteUser(@PathVariable int id) { User user = service.deleteById( id); if(user == null) { throw new UserNotFoundException(String.format("ID[%s] not found ", id)); } }}사용했는데 에러가 발생했습니다 ㅠㅠorg.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.plugin.core.PluginRegistry<org.springframework.hateoas.client.LinkDiscoverer, org.springframework.http.MediaType>' available: expected single matching bean but found 3: relProviderPluginRegistry,linkDiscovererRegistry,entityLinksPluginRegistry
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
swagger 연동을 할려고 하는데 에러가 발생합니다
지금 현재 swagger 해보고 있는데 org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoClassDefFoundError: javax/validation/constraints/NotBlank 이런 에러가 발생했습니다 구글링 해보니 이거 버전 안맞다는 말이 많더라구요 버전은 강의를 보면서 하고 있어서 최신 버전을 했는데 다른 문제를 모르겠습니다 ㅠㅠ ㅇㄹㅇㄹㅇㄹ
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
스프링부트 2.5 강좌 디펜던시 최신 기준
할 브라우저 설치하지 마시고 할 익스플로러 설치하시면 됩니다. 인터페이스가 조금 다른데 별 차이 없습니다. <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-rest-hal-explorer</artifactId> <version>3.5.1</version></dependency>
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
기본 언어가 영어로 출력됩니다.
messages.properties -> greeting.message=안녕하세요. 기본 프로퍼티스 파일 위와 같이 1개만 두고 실행하면 당연히 한글이 나옵니다. 이후 프랑스, 영어 추가해서 포스트맨에서 액셉트 설정하면 각각의 언어로 잘 나옵니다. 다만, 3개의 파일을 같이 두고 실행하면 기본 실행이 영어로 나옵니다. 이유를 모르겠습니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
강의자료 ppt
안녕하세요! 혹시 강의에 사용된 ppt자료는 어떻게 받을 수 있나요? 인쇄 후 필기해가면서 수강하려고 하는데, 다운받는 곳을 못찾겠습니다 ㅠㅠ 감사합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
Swagger와 Jackson Filter 사용 시 Swagger-ui의 example value
Jackson Filter를 적용한 코드에서는 Swagger-UI에서 example value 값이 "filters"와 "value"로만 보입니다. 필터가 적용된 example value 값을 온전히 표시하기 위해서는 어떻게 해야하는지 궁금합니다.
- 미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
테이블 생성 전 insert
안녕하세요. 강의 잘 듣고 있습니다. data.sql 없을 땐 테이블 생성 되고 문제 없었는데 data.sql 파일을 만드니까 테이블 생성하기 전에 insert를 해서 에러가 나는 것 같습니다. 어떻게 해결하면 좋을까요.. insert into user values(1, sysdate(), "eony", "asdf", "941010-2020200"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USER" not found; SQL statement: insert into user values(1, sysdate(), "eony", "asdf", "941010-2020200") [42102-200] Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/Users/eony/workspace/study/%ec%9d%b8%ed%94%84%eb%9f%b0%ea%b0%95%ec%9d%98/restful-web-service/target/classes/data.sql]: insert into user values(1, sysdate(), "eony", "asdf", "941010-2020200"); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "USER" not found; SQL statement: insert into user values(1, sysdate(), "eony", "asdf", "941010-2020200") [42102-200]