비동기 시리즈
0편:스프링 초기세팅하기
1편:javax.mail로 메일보내기 - https://dev-dx2d2y-log.tistory.com/103
1.5편:내부클래스로 코드 간략화 - https://dev-dx2d2y-log.tistory.com/104
2편:비동기처리로 클라이언트 풀어주기 - https://dev-dx2d2y-log.tistory.com/108
***************************
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
연습용 스프링 프로젝트를 하나 만들어서 실행하려했는데 이렇게 오류가 뜬다.
프로젝트를 불러올 때 DB가 연결되지 않아서 생기는 오류로, DB를 연결해주면 된다.
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:~/test
spring.datasource.username=DDD
spring.datasource.password=
spring.sql.init.mode = always
그래서 application.properties를 열어 다음과 같이 작성하여 DB를 연결해줬다.
사실 DB가 필요하지 않은 간단한 프로젝트라 그냥 H2로만 연결해줘도 되어서 이렇게 설정했고

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
이 부분은 H2DB를 활성화하는 것과 접근할 URL 경로를 뜻한다. 즉, H2DB에 접근하고 싶을 때는 localhost:8080/h2-console로 접근하면 된다.
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:~/test
spring.datasource.username=DDD
spring.datasource.password=
spring.sql.init.mode = always
이 요소들은 위 H2DB에 접근했을 때의 줘야할 인자들이다. 자유롭게 설정할 수 있고, username과 password를 기억해뒀다가 입력하여 DB에 접근해야한다.
그러면 저 문제는 해결된다.
나는 DB연결 전 기초적인 작업일 뿐더러 프로젝트가 DB 성능이 크게 중요하지 않은 간단한 프로젝트라서 H2DB로 한거고 다른 DB를 사용할 것이면 각자에게 맞는 DB를 사용함이 좋을듯하다.
나중에 MySQL을 다루면 그 때 또 업데이트 할 예정
아마 MySQL은 각 DB마다 MySQL에서 설정한 닉네임과 비밀번호, 연결할 URL 링크를 넣어줬어야했나 그랬던걸로 기억한다.
https://dev-dx2d2y-log.tistory.com/51
[GDG] 홍대 맛집 아카이빙 프로젝트 #20 - mySQL과 각종 코드 보강하기
mySQL 사용하기오늘은 H2DB를 벗어나서 MySQL로 DB를 연동시켜볼까 한다. 기본적으로는https://chaeyami.tistory.com/244 [SpringBoot] JPA + MySQL 연동MySQL과 Workbench 설치MySQL 설치하기 [MySQL] MySQL, MySQL Workbench 설치
dev-dx2d2y-log.tistory.com
application.properties가 아닌 application.yml로 작성해 MySQL과 연결했던 게시글이 있으니 이걸 참고해도 될 듯하다.
