간단 요약
Spring Boot 3.4.x에서 Spring Data JPA를 통해 DBMS에 연결을 할 때, 설정들을 모두 제대로 했음에도 정보성 로그로 Hibernate가 Database 정보 항목들 다수를 undefined/unknown으로 출력하는 것은 정상이므로 무시하면 됩니다. 관련된 원인을 알고 싶은 경우에는 아래 내용을 확인하세요.
Spring Boot 3.4.x에서 Spring Data JPA를 사용하여 MySQL(또는 MariaDB)를 접속하게 설정을 하여 기동을 하면 다음과 같이 설정이 잘 못 된 거 같아 보이는 로그가 출력됩니다.
단순히 보면 HikariCP의 설정을 application.yml에 설정하지 않아서 그런가 하고 생각할 수 있지만, 관련된 항목을 다 설정해도 계속 undefined/unknown으로 나오게 됩니다.
이 와 관련해서 좀 찾아보면 다음과 같이 질문하고 논의하는 내용들을 좀 볼 수 있습니다.
https://www.reddit.com/r/SpringBoot/comments/1h7v33r/i_am_getting_this_error/
From the SpringBoot community on Reddit
Explore this post and more from the SpringBoot community
www.reddit.com
https://github.com/spring-projects/spring-boot/issues/43321#issuecomment-2507258543
Bug: JDBC returning undefined/unknown database driver · Issue #43321 · spring-projects/spring-boot
Database JDBC URL [Connecting through datasource 'HikariDataSource (HikariPool-1)'] Database driver: undefined/unknown Database version: 8.0.39 Autocommit mode: undefined/unknown Isolation level: u...
github.com
답은 2번째 URL의 내용에 있기는 합니다만, 정확한 원인은 다음과 같습니다.
Spring Boot가 3.3.x에서 3.4.x로 업그레이드 되면서 spring-boot-starter-jpa에 의해 추가되는 hibernate의 버전이 6.5.3에서 6.6.8로 변경됐습니다(최하위 버전은 다를 수 있습니다). Hibernate의 버전이 올라가면서 JDBC 연결 풀(pool) 관련된 클래스 체계가 변경됐습니다. 6.6.8에서는 이러한 변경된 체계 중에 DatasourceConnectionProviderImpl라는 클래스를 사용하게 되는데, 이 클래스에 보면 로그에 찍는 데이터베이스 연결 정보를 반환하는 메소드에 대부분의 정보를 null로 설정하고 있습니다.
@Override
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
return new DatabaseConnectionInfoImpl(
"Connecting through datasource '" + (dataSourceJndiName != null ? dataSourceJndiName : dataSource) + "'",
null,
dialect.getVersion(),
null,
null,
null,
null
);
}
여기에서 DatabaseConnectionInfoImpl 클래스의 생성자를 보면 다음과 같습니다.
public DatabaseConnectionInfoImpl(
String jdbcUrl,
String jdbcDriver,
DatabaseVersion dialectVersion,
String autoCommitMode,
String isolationLevel,
Integer poolMinSize,
Integer poolMaxSize) {
this.jdbcUrl = nullIfEmpty( jdbcUrl );
this.jdbcDriver = nullIfEmpty( jdbcDriver );
this.dialectVersion = dialectVersion;
this.autoCommitMode = nullIfEmpty( autoCommitMode );
this.isolationLevel = nullIfEmpty( isolationLevel );
this.poolMinSize = poolMinSize;
this.poolMaxSize = poolMaxSize;
}
그리고 이 클래스의 상단에는 null에 대한 기본값으로 다음과 같이 상수 필드가 정의돼 있습니다.
public static final String DEFAULT = "undefined/unknown";
이렇게 클래스의 메소드에 하드 코딩으로 항목들의 값이 null로 지정돼 있어서 관련 정보가 출력되지 않고 undefined/unknown이 출력되는 것입니다. DatasourceConnectionProviderImpl 클래스의 해당 부분과 전체 코드는 다음의 URL에서 보실 수 있습니다.
hibernate-orm/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
Hibernate's core Object/Relational Mapping functionality - hibernate/hibernate-orm
github.com
그래서, 설정을 제대로 했다면 undefined/unknown 이 출력되는 것은 그냥 무시해도 됩니다.
사소한 문제일 수도 있지만, Hibernate 6.6.x 대에서 고쳐주면 좋으련만 Source Repository에서의 활동을 보면 7.0.0에서 보완을 하려고 하는 듯 보입니다. 해당 내용은 다음의 commit에서 확인할 수 있습니다. 아직 7.0.0이 베타단계에서 정보를 더 추가할지는 모르겠지만, 그래도 몇 가지 정보를 더 추가했습니다.
https://github.com/hibernate/hibernate-orm/commit/a6aeeba8fe09ae9acce8f2e384f8b73676bfe862
HHH-18989 log more info when DataSource is used · hibernate/hibernate-orm@a6aeeba
get it from the DatabaseMetaData
github.com
'알쓸신잡' 카테고리의 다른 글
Java - JSR, JEP (1) | 2025.02.20 |
---|---|
Grok vs Groq (0) | 2025.02.19 |
AI계의 메기 - DeepSeek (2) | 2025.01.28 |
샘 앨트먼, "전통적으로 이해해온 AGI를 구축하는 방법에 대해 이제 우리는 확신을 갖고 있습니다" (0) | 2025.01.07 |
open weights 의미 (2) | 2024.10.30 |