개발 공부 기록하기/04. Spring & Spring Boot 10

Unable to find method java.lang.String org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper.getKotlinPluginVersion() 원인

회사에서 사용하는 프로젝트의 언어 (Kotlin), 프레임워크 (Spring Boot) 최신화를 하려고 하는 중인데 Unable to find method ''java.lang.String org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper.getKotlinPluginVersion()'' 'java.lang.String org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper.getKotlinPluginVersion()' Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-downloa..

[Kotlin + Spring Boot + Querydsl] gradle multi project 구성하기

안녕하세요! 공부하는 개발자 입니다! 이번 포스트에서는 Kotlin, Spring Boot, Querdsl을 이용하여 gradle multi porject를 구성하는 방법에 대해 알아보겠습니다. 본 포스트를 작성하게 된 계기는 최근 이직한 회사의 프로젝트 구성이 git repository N개와 git submodule을 사용한 형태였기 때문인데요, 따라서 gradle multi module의 본격적인 구성 방법을 살펴보기에 앞서, 한 시스템 내에서 사용되는 모듈을 관리할 수 있는 또 다른 방법인 git repository N 개 + git submodule 에 대해서 간단히 설명드려 보겠습니다 🙂 Git repository N개 + Git submodule 방식 사실 생각해보면 꼭 gradle mult..

Unable to load AWS credentials from any provider in the chain 해결

spring-cloud-aws 를 사용할때 이런 에러가 날 수 있다. com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@64c19877: Failed to connect to service endpoint: , com.amazonaws.auth.profile.ProfileCredentialsProvider@7f570ac4: profile file cannot be null 이 경우, credeitnals를 넣어주어야 하고 몇 가지 해결책이 있다. 1. Access Key 발급받아..

Failed to connect to service endpoint (Warning) 해결

spring-cloud-aws를 이용한 프로젝트를 로컬에서 실행시킬때 Application 자체는 잘 뜨는데 이런 Warning이 날 때가 있다. com.amazonaws.SdkClientException: Failed to connect to service endpoint Caused by: java.net.SocketTimeoutException: connect timed out 이런 Warning이 나는 코드를 살펴보면, public final class AwsCloudEnvironmentCheckUtils { private static final String EC2_METADATA_ROOT = "/latest/meta-data"; private static Boolean isCloudEnviron..

There is no EC2 meta data available, because the application is not running in the EC2 environment 해결

build.gradle에 spring-cloud-aws-autoconfigure 을 설정하고 로컬에서 실행시키면 다음과 같은 에러가 나올 수 있다. (줄바꿈 추가) Caused by: java.lang.IllegalStateException: There is no EC2 meta data available, because the application is not running in the EC2 environment. Region detection is only possible if the application is running on a EC2 instance 에러를 해석해보면, application이 돌아가는 환경이 EC2가 아니라 meta data가 없다는 뜻이다. 오호.. region 정보를 추가..

Failed to instantiate StackNameProvider 해결

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackNameProvider]: Factory method 'autoDetectingStackNameProvider' threw exception; nested exception is java.lang.IllegalArgumentException: No valid instance id defined Spring Cloud AWS 의 auto configure를 이용할때 위와 같은 에러가 날 수 있다. 이럴때는.. cloud: aws: stack: auto..

Spring Boot Interceptor에서 권한 관리하기 I (HttpServletRequest getInputStream 여러번)

백엔드를 리딩하며 개발하고 있는 사이드 프로젝트에서 권한을 꽤나 복잡하게 관리해야 하는 요구사항이 있었다. 사이드 프로젝트에서는 원격 근무 협업툴을 만들고 있는데, 협업툴 답게 Team이라는 개념이 있으며 여러 유저가 각기 다른 여러 Team에 가입할 수 있다. Team에 가입한 사용자들은 팀 내부에서 역할(ex 관리자, 일반 멤버)이 정해지며 각 역할에 따라 사용할 수 있는 기능이 달라진다. 또한, Team 내부에는 여러 Part가 있고 Part에서만 사용할 수 있는 기능들이 존재한다. 사용자와 팀, 파트 외에도 팀이 사용하고 있는 Plan에 따라서 (Free Plan, Premium Plan 등) 사용할 수 있는 기능도 달라져야 한다. 에헴... 서버는 어쨌거나 특정 API 호출 권한을 확인해야할 책..

Spring Boot SQL 보기 옵션 총 정리

Spring Boot에서 query DSL을 사용하건 spring boot JPA를 사용하건, 쿼리를 튜닝할 때 SQL을 봐야할 때가 있다. 그럴 때 사용할 수 있는 몇 가지 옵션을 조사해 보았다. 환경 : Spring boot 2.* + hibernate 5.3.10 이상 sql 보기 Hibernate이 DB에 날리는 모든 쿼리(DDL, DML)를 보여준다 application.yml을 사용한다면, spring: jpa: properties: hibernate: show_sql: true application.properties를 사용한다면, spring.jpa.properties.hibernate.show_sql=true 추가된 로그 Hibernate: select user0_.id as id1_0_..

Spring REST DOCS를 Spring Boot에 적용하기 (2)

본 포스팅에서는 Spring Boot에 적용된 Spring REST Docs를 보다 잘 활용하는 방법에 대해 기술합니다! 적용하는 방법은 여기를 참고해 주세요! request, response 변경하기 기본적으로 나오는 http-request.adoc과 http-response.adoc에서 한 두가지 정도를 변경해보자 JSON을 더 보기 좋게 기본적으로 나오는 json은 한 줄로 취급된다. 하지만 이것을 조금 더 이쁘게 출력하고 싶다면 prettyPrint()를 사용하면 된다. mockMvc.perform(get("/api/v1/data")) .andDo(print()) .andExpect(status().isOk()) .andDo(document("signup"), preprocessRequest(pr..

Spring REST DOCS를 Spring Boot에 적용하기 (1)

주요 REF Spring REST DOCS DOCU Asciidoctor 본 포스팅에선 1) Spring REST DOCS가 무엇인지 2) gradle + mockMvc 환경에서 Spring REST DOCS를 Spring BOOT에 어떻게 "기본" 적용하는지 다루고 있습니다! Spring REST DOCS를 "활용"하는 방법은 여기를 참고해 주세요! Spring REST DOCS란? 일단 Spring REST DOCS의 정의는 이렇다. 1) Spring MVC TEST에 의해 2) 자동 생성된 snippet과 3) 직접 작성한 문서를 결합하여 최종 Documentation을 만들어 주는 서비스 여기서 포인트는 3가지 이다. Spring MVC TEST - snippet 만드는 방법은 Spring MVC..