java/에러

Failed to load ApplicationContext 에러 해결(오타)

sungin95 2023. 8. 4. 18:19
Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98)
	....
Caused by: org.springframework.beans.factory.BeanCreationException: 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.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
	at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
    ...
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
	at app//org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:284)
    ...
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
	at app//org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)
    ...

데이터 베이스 연결을 위해 application.yaml 파일을 추가해 테스트를 해 보니 이런 오류가 났었습니다.

debug: false
management.endpoints.web.exposure.include: "*"


logging:
  level:
    com.fastcampus.projectboard: debug
    org.springframework.web.servlet: debug
    org.hibernate.type.descriptor.sql.BasicBinder: trace

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/board
    username: dlrkehrud
    password: thisisTESTpw!#%&
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    defer-datasource-initialization: true

    hibernate.ddl-auto: create
    show-sql: true
    properties:
      hibernate.format_sql: true
      hibernate.default_batch_fetch_size: 100
  h2.console.enabled: true
  sql.init.mode: always

---

spring:
  config.activate.on-profile: testdb

org.hibernate.HibernateException문제인가 해서 Dialect등 추가 설치 해 보았으나 오히려 다른 문제가 생겼습니다. 

 

그러다 찾아낸 오류는 오타... 

비밀번호에 실수로 스페이스바를 넣어서 안되던 거였습니다...

그런데 이 에러를 보고 오타일거라고 생각을 못했었는데... 

다들 조심하세요~~~

 

 

https://2dongdong.tistory.com/66

https://velog.io/@oyoungsun/Spring-Failed-to-load-ApplicationContext-%EC%97%90%EB%9F%AC-%ED%95%B4%EA%B2%B0