springboot

    [SpringBoot][Kotlin] org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing 에러

    [SpringBoot][Kotlin] org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing 에러

    실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발 강의를 들으면 주문서비스 테스트를 작성하고, 실행했는데 에러를 만났다. 반가워~👋 에러메세지 org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.jpabook.jpashop.domain.Order.delivery -> com.jpabook.jpashop.domain.Delivery; nested exception is java.la..

    [JUnit5][SpringBoot][Kotlin] Exception테스트하기 (assertThrows)

    [JUnit5][SpringBoot][Kotlin] Exception테스트하기 (assertThrows)

    JUnit4 Junit4에서 exception 테스트는 @Test(expected=기대하는예외)를 통해 가능하다. (JUnit5와 비교하기 위한 예시코드이므로 정확하진 않을 수 있음) @Test(expected = NotEnoughStockException::class) fun 상품주문_재고수량초과() { val member = createMember("사용자") val book = createBook("도서명", 10000, 10, "저자명", "12345") val orderCount = 11 orderService.order(member.id!!, book.id!!, orderCount) fail("예외가 발생해야 한다."); } JUnit5 @Test에 expected를 쓸 수 없게 되어있어 다른..

    [Spring Boot] No tests found for given includes: 에러

    [Spring Boot] No tests found for given includes: 에러

    Spring Boot로 테스트 작성 후 IntelliJ내의 테스트 실행버튼을 눌러 테스트를 시도했다. 그런데... Execution failed for task ':test'. > No tests found for given includes: [test코드 경로](filter.includeTestsMatching) * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. 이렇게 떴다..!! 분명 @Test가 붙은 테스트들이 존재하는데...왜 없다고 하는 것인가? 인프런에 나와..

    [Spring Boot] Error creating bean with name 'entityManagerFactory' defined in class path resource

    [Spring Boot] Error creating bean with name 'entityManagerFactory' defined in class path resource

    Spring Boot, Kotlin, JPA, H2를 이용해서 API 테스트코드를 작성중이었다. Error creating bean with name 'entityManagerFactory' defined in class path resource Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceExcepti..

    [Spring Boot] 오류: Cannot construct instance of (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

    [Spring Boot] 오류: Cannot construct instance of (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

    정말 오랜만에 작년에 진행했던 프로젝트의 서버를 다시 살려보았다. 겨우 살리는데는 성공을 했는데, API호출을 해보니 500에러가 난다!ㅠㅠ 🚨 에러메세지 Cannot construct instance of `model` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) 문제가된 'model' 위치에는 req, res에 사용되는 dto class가 있었다. import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lom..

    [Springboot][EC2] 로컬에서 빌드하고 빌드파일만 업로드하기

    [Springboot][EC2] 로컬에서 빌드하고 빌드파일만 업로드하기

    원래는 EC2에 코드를 올려서 build 하고, 수행하게 되는데 EC2 사양이 그렇게 좋지 않다보니 무리가 갈때가 있다! 그래서 가끔 EC2가 먹통이 되곤 했다... 그래서 로컬에서 빌드하고, 서버에 업로드해서 사용하면 괜찮다고 해서 시도!! 먼저 로컬에서 EC2에서 빌드하는 것과 같이 빌드를 수행해준다 ./gradlew build 수행하면 프로젝트 폴더에 build 폴더 안에 libs 폴더가 생긴다! libs 폴더 안을 보면 jar 파일이 생성되어 있을 것이다 우리는 이 jar파일만 EC2에 업로드 시켜주면 된다 파일업로드는 Filezila, 사이버 덕 등을 이용하여 EC2에 SFTP접속을 해서 파일업로드를 시켜주면 된다 나는 사이버덕을 사용해보았다 EC2에서 해당 서버의 루트경로인 var/www/~로..

    [SpringBoot][AWS EC2] nohup을 이용하여 무중단 서비스 만들기

    [SpringBoot][AWS EC2] nohup을 이용하여 무중단 서비스 만들기

    빌드 먼저 Git을 통해 받은 프로젝트 폴더로 이동하여, build를 진행한다. ./gradlew build build가 완료되었다 실행 java -jar build/libs/demo-0.0.1-SNAPSHOT.jar 정상적으로 잘 실행되었다. 하지만 이상태에서 터미널을 종료하면 실행중인 java도 같이 종료되어 버린다! 무중단 서비스를 위해 nohup을 이용하여 백그라운드에서 실행시키자 nohup nohup java -jar build/libs/demo-0.0.1-SNAPSHOT.jar & > /dev/null 아까 실행시킬 때 수행했던 명령어 앞에 nohup을 붙이고, 뒤에 &을 붙이면 백그라운드에서 실행이 되어, 터미널을 종료해도 EC2상에서는 계속 돌아간다, 뒤에 > /dev/null은 log를 ..

    [SpringBoot] 에러 : JSON parse error: Cannot construct instance of~

    [SpringBoot] 에러 : JSON parse error: Cannot construct instance of~

    Spring Boot에서 POST방식을 처음 사용하는데, JSON parse error: Cannot construct instance of~ 이라는 에러가 났다ㅜㅜ Body로 보낸 json파일을 읽지를 못하는 것 같았다 타입이 잘못됬나해서 이것저것 바꿔봤는데 아주 간단했다... @RequestBody부분에서 받아올때부터 에러가 난다! 해결방법 Header에 "Content-Type": "application/json" 를 추가해주니까 된다 만약 이 방법으로 안된다면, model class에 @JsonAutoDetect 추가해보길 참고) 그리고 위 model Class는 속성이 2개 인데, 1개만 넣었을 때도 에러가 났다! 1개만 포함하고 있는 Class는 model로 안봐주는 것인가..?!