본문 바로가기
개발언어/Java

springboot initializer 로 jpa library 추가 후 실행 오류

by 공장장코난 2021. 12. 17.

springboot initializer로 jpa를 추가한 project 생성 후 initellij로 실행시 아래 오류가 발생한다. 
처음엔 build.gradle 파일에서 jpa 부분만 제거 후 실행 동작하길래 project 빌드가 잘못된것으로 알았다. 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Process finished with exit code 1

하지만, 구글링해보니 연결할 database에 대한 정보가 없어 발생한 오류로 application.properties에 database 연결 정보를 구성 한다. (mysql 기준)

#DB Connection information
spring.datasource.url=jdbc:mysql://localhost:3306/test_db?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=test
spring.datasource.password=1q2w3e4r5t
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

#MySql use
spring.jpa.database=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect

#Logging level
logging.level.org.hibernate=info

#Outputs all sql statements executed by Hibernatge to the console
spring.jpa.properties.hibernate.show_sql=true

#Representing SQL statements in a readable way
spring.jpa.properties.hibernate.format_sql=true

#Debugging information output
spring.jpa.properties.hibernate.use_sql_comments=true

실행 완료!!, 다시 개발 시작