RestTemplate 와 ObjectMapper 활용기(스프링에서 다른 서버의 JSON API Token 을 가져와서 이용해야 할 때)
·
Framework & Runtime/SpringBoot
우선 API 서버의 스펙을 확인하고 data class 를 만들어 줍니다. data class GetToken( val responseCode: String, val token: String ) Http Request 이후 Json 을 담아줄 클래스에 아래 내용을 추가해 줍니다. @Autowired lateinit var restTemplate: RestTemplate var mapper: ObjectMapper = ObjectMapper().registerModules(KotlinModule()) 펑션을 하나 만드셔서 안에 아래 내용을 작성하기 시작합니다. val headers = HttpHeaders() headers.contentType = MediaType.APPLICATION_JSON conte..
Kotlin Spring Boot 에 Querydsl 종속성이 추가된 프로젝트 소스 공유
·
Framework & Runtime/SpringBoot
스프링 이니셜라이저에는 왜 querydsl 이 없는가! 그래서 제가 공개 템플릿 레포를 하나 만들었습니다. https://github.com/Kuass/Kotlin-Spring_Boot-Example GitHub - Kuass/Kotlin-Spring_Boot-Example: Why isn't there a querydsl in the spring initializer! Why isn't there a querydsl in the spring initializer! - GitHub - Kuass/Kotlin-Spring_Boot-Example: Why isn't there a querydsl in the spring initializer! github.com
(백준/Kotlin) 10818번 : 최소, 최대 (시간 복잡도/선형 시간, 메소드 성능 비교)
·
CodingTest
난이도: Bronze 3 프로그래밍 언어: Kotlin 문제명: 최소, 최대 푼일자: 2021년 6월 주소: https://www.acmicpc.net/problem/10818 문제풀기 단순한 선형 시간 O(n) 문제이다. 제출하고, 생각나는 몇가지 방법이 있어 각각 백준에 제출을 해서 성능을 비교해 보았다. MutableList 형에서 지원하는 .min() 과 .max() 를 사용해 보았다. fun resolve1() = with(Scanner(System.`in`)) { nextLine() val r = nextLine().split(" ").map { it.toInt() }.toTypedArray().toList() print("${r.minOrNull()} ${r.maxOrNull()}") } M..
(백준/Kotlin) 2839번 : 설탕 배달(해설)
·
CodingTest
난이도: Bronze 1 프로그래밍 언어: Kotlin 문제명: 설탕 배달 푼일자: 2021년 6월 주소: https://www.acmicpc.net/problem/2839 문제풀기 매번마다 현재 가지고 있는 설탕을 5로 나눈 나머지가 0일 경우 5로 완벽하게 나누어 지는 것이다. (혹은 0kg 이거나) 그럼 나누기의 값은 5kg 가방의 개수가 될 것이다. 완벽하게 나누어 지지 않을경우 작은 플라스틱 가방인 3kg 가방을 하나씩 추가해 가며 설탕을 3kg 씩 줄여준다. 그러다가 설탕이 0 과 같거나 작아질 때(음수) -1 을 출력한다. 완벽히 나눌 수 없기 때문이다. import java.util.* fun main() = with(Scanner(System.`in`)) { var sugar = next..
(백준/Kotlin) 11050번 : 이항 계수 1
·
CodingTest
난이도: Bronze 1 프로그래밍 언어: Kotlin 문제명: 이항 계수 1 푼일자: 2021년 6월 주소: https://www.acmicpc.net/problem/11050 문제풀기 코틀린으로 한번 풀어봤습니다. import java.util.* fun main() = with(Scanner(System.`in`)) { var a = nextInt() var b = nextInt() print(loop(a) / (loop(b) * loop(a-b))) } fun loop(x: Int): Int { var r = 1; for (i in x downTo 1) r *= i return r }