원인: org.hibernate.휴지 상태예외:Language Resolution 접근'hibernate.dialect'가 설정되지 않은 경우 정보는 null일 수 없습니다.
hibernate.dialect 속성을 설정한 후에도 예외가 발생합니다.스프링 부트 1.4.2와 mysql 버전 5.7에서 휴지 상태 5.0.11을 사용하고 있습니다.
application.properties is like this
# Hibernate
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=validate
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
여기서의 문제점은 무엇입니까?
에 다음 행 추가properties
file은 내가 그 오류가 발생했을 때 이 문제를 해결합니다.
spring.jpa.database=mysql
저도 비슷한 문제가 있었습니다만, Springboot의 튜토리얼에서 작성한 application.properties 파일에 복사하여 붙여넣기 하는 DB 이름 필드를 제대로 커스터마이즈하지 않았다는 것을 깨달았습니다.
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
반드시 교환해 주세요.db_example
springuser
그리고.ThePassword
당신의 실제 가치로요.
나 자신에게는 "아찔한" 순간이지만, 다른 사람들에게는 어느 정도 도움이 될 수 있다.
아마 이미 해결하셨겠지만, 저도 비슷한 문제가 있었습니다.
mysql에 명시적인 런타임 의존성을 추가하면 문제가 해결됩니다.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
이것에 의해, spring boot 에서는 클래스 패스에 근거해 jdbc 관련의 콩을 자동 설정할 수 있습니다.
Configuration 작성 후 다음을 추가하여 문제를 해결합니다.
configuration.configure("hibernate.cfg.xml");
난 노골적으로 놓치고 있었어
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
또한 이 게시물에는 org.hibernate라는 유용한 팁이 있습니다.휴지 상태예외: Language Resolution 접근'hibernate.dialect'가 설정되지 않은 경우 정보는 null일 수 없습니다.
내 경우 데이터베이스를 제외한 상태에서 스프링 부트 응용 프로그램을 시작했습니다.
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class})
그런 다음 JPA 클래스를 만들기 시작하면 다음 오류를 수정하려고 했습니다.
@Bean(name = "entityManagerFactory")
public LocalSessionFactoryBean sessionFactory() {
return new LocalSessionFactoryBean();
}
이로 인해 질문에서 언급된 예외가 발생했습니다.
그래서 해결책은 간단히 제거되는 것이었습니다.DataSourceAutoConfiguration.class
에서@SpringBootApplication
물론 주석을 달았지만, 오류를 알아차리기까지 시간이 좀 걸렸습니다.
Oracle 데이터베이스에 접속했을 때 Spring 부트프로젝트에서도 같은 문제가 발생하였습니다.
다음은 트러블 슈팅을 위해 수행한 순서입니다.
관련된 휴지 상태 속성이 application.properties 파일에 있는지 확인합니다.
hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
,spring.jpa.hibernate.ddl-auto=update
사용하는 데이터베이스에 따라 사투리가 달라집니다.또,
hibernate.ddl-auto
5가지 속성 중 하나가 될 수 있습니다.JDBC URL 을 확인합니다.예를 들어 Oracle의 연결 문자열은 다음과 같습니다.
jdbc:oracle:thin:@10.10.32.20:1521/SRV_LICENSING_D1
데이터베이스 자격 증명을 확인합니다.
속성 파일에서 사용된 서비스 이름이 대문자인지 확인하십시오.최대 절전 모드는 대소문자를 구분합니다.예를 들어 Oracle의 경우 서비스 이름은 다음과 같습니다.
SRV_LICENSING_D1
이유: 데이터베이스 연결이 충족되지 않는 반면 db의 방언은 중요하지 않습니다.
솔루션:application.properties(또는 어디에 있는지)의 연결 문자열을 수정합니다.
언어 해결사은 아니었다.public
실수 인인) : )
언급URL : https://stackoverflow.com/questions/40779664/caused-by-org-hibernate-hibernateexception-access-to-dialectresolutioninfo-can
'programing' 카테고리의 다른 글
json을 사용하여 JSON을 디코딩하고 있습니다.언마샬 vs json.NewDecoder.디코드 (0) | 2023.03.26 |
---|---|
올바른 형식으로 JSON 파일에 쓰는 방법 (0) | 2023.03.26 |
Angular에 대한 캔버스 그리기 지침이 이미 있습니까?밖에 JS? (0) | 2023.03.26 |
pandas.io.json.json_normalize with very nested json (0) | 2023.03.26 |
Python 요청:JSON과 파일을 단일 요청으로 게시 (0) | 2023.03.26 |