5. 그 외 공부/5.1 ERROR

[SpringBoot JPA]org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 1;..

마느링 2022. 9. 22. 11:27

쪽팔리지만..올려본다..

 

스프링 부트 JPA 수업중 테스트 코드를 작성하다가 하기와 같이 오류가 떴다.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.jpa-org.springframework.boot.autoconfigure.orm.jpa.JpaProperties': Could not bind properties to 'JpaProperties' : prefix=spring.jpa, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.jpa.properties' to java.util.Map<java.lang.String, java.lang.String>

 

이게 뭐지???? 구글링하고 삭제해서 다시 입력하고 별 생쇼를 다함...한시간 넘게 생쇼함..

그런데 나의 어이없는 실수...ㅋㅋㅋㅋ(역시나..)

그동안 application.properties로 설정해서 설정할때 별 생각없이 입력했는데

application.yml은 계층구조 때문에 띄어쓰기를 2칸을 해주어야하는데... 

나는 아래와 같이 한칸만 띄어쓰기를 해주었다...이러니까 인식을 못한거지 멍충아...

코드 입력에만 급급하여 강의자료를 제대로 안본 내가 멍충이다..

<Before>

spring:
  datasource:
  url: jdbc:h2:tcp://localhost/~/jpashop
  username: sa
  password:
  driver-class-name: org.h2.Driver

  jpa:
    hibernate:
    ddl-auto: create
    properties:
  hibernate:
  # show_sql: true    #system.out으로 찍음
  format_sql: true

logging.level:
  org.hibernate.SQL: debug
# org.hibernate.type: trace

다시 두칸으로 띄어쓰기 하고 정상적으로 작동되었다.. ㅠㅠㅠㅠㅠ

<After>

spring:
  datasource:
    url: jdbc:h2:tcp://localhost/~/jpashop
    username: sa
    password:
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        #        show_sql: true
        format_sql: true

logging.level:
  org.hibernate.SQL: debug
#  org.hibernate.type: trace

오류를 겪으면서 느낀거지만

설정파일에서 띄어쓰기, 오타 등 정말 사소한부분에서 생기는 실수때문에 오류가 생기는게 대부분이었다

ide가 다 도와주는데도...

앞으로 조심해야지..(언제쯤 이런 어이없는 에러파티를 안겪을 수 있을까)