본문 바로가기
728x90

Back-End23

MVC 컨트롤러 List로 받기 1. Class @Getter @Setter @ToString public class MemberDelete{ Long id; } 2. 컨트롤러 ( Delete 메소드일 때 ) @Transactional @DeleteMapping("/api/v1/members") public void deleteMember(@RequestBody List memberRequest){} 3. 전송 Json [ { "id" : 1 }, { "id" : 2 } ] 2021. 3. 14.
스프링 컨트롤러에서 json 받기 (feat. 포스트맨) 1. @RequestBody 를 적으면 json을 받는다. - 적지 않으면 parpameter를 받는다. (http://localhost:8080?id=1 에서 id) //parameter로 받는 경우 @GetMapping("/api/v1/members") public Page selectMembers(MemberRequest.MemberSearch memberRequest, Pageable pageable){ return memberRepository.findMember( memberRequest, pageable); } //Json으로 받는 경우 @PostMapping("/api/v1/members") public Long insertMember(@RequestBody MemberRequest.Mem.. 2021. 3. 14.
[Spring Cloud Config] Client yml 환경변수로 작성하기 1. Config Server와 연동된 applicationName-profilesName.yml 파일 spring: datasource: url: jdbc:mysql://ip:port/DatabaseName?serverTimezone=UTC&characterEncoding=UTF-8 username: id password: pw driver-class-name: com.mysql.cj.jdbc.Driver jpa: show-sql: true management: endpoints: web: exposure: include: ["env", "refresh"] 2. Client의 application.yml 파일 에서 값 받기 (bootstrap.yml 불필요 최신버전) server: port: 8080 .. 2021. 2. 22.
[Spring Cloud Config] Client 의 bootstrap.yml 지원 만료 스프링 클라우드 config client 에서 bootstrap.yml을 더이상 지원하지 않는다. 예전 자료들이 전부 bootstrap.yml 기반이라서 많이 해맸다. 하루는 해맨거 같다. stackoverflow : java - Config Client is not working in Spring boot - Stack Overflow 2020.0.0 업데이트 내용 : Spring Cloud 2020.0 Release Notes · spring-cloud/spring-cloud-release Wiki · GitHub spring 공식 문서 : Spring Cloud Config 이제 bootstrap.yml 대신 application.properties 또는 application.yml 에 spring.. 2021. 2. 22.
728x90