Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:301) ~[postgresql-42.3.1.jar:42.3.1] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.3.1.jar:42.3.1] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225) ~[po|
이런 에러가 콘솔에 등장했다.
분명 application.yml도
spring:
jpa:
hibernate:
format_sql: true
use_sql_comments: true
ddl-auto: create
show-sql: true
database: postgresql
datasource:
# url: jdbc:h2:mem:testdb
url: database-1.c8.ap-northeast-2.rds.amazonaws.com
username: postgres
password: postgres2023!
driver-class-name: org.postgresql.Driver
# h2:
# console:
# enabled: true
defer-datasource-initialization: true
이렇게 넣었었고
build.gradle 도
implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.1'
runtimeOnly 'org.postgresql:postgresql'
이렇게 넣었는데
원인은 .yml 파일의 url을 저렇게 바로 복붙해서 넣으면 안되었다.
평소 디비버나 디비툴에 연동시킬때처럼 했더니 오류가 난것이다.
저 부분을
spring:
jpa:
hibernate:
format_sql: true
use_sql_comments: true
ddl-auto: create
show-sql: true
database: postgresql
datasource:
# url: jdbc:h2:mem:testdb
url: jdbc:postgresql://database-1.c8.ap-northeast-2.rds.amazonaws.com/postgres
username: postgres
password: postgres2023!
driver-class-name: org.postgresql.Driver
# h2:
# console:
# enabled: true
defer-datasource-initialization: true
이렇게 //와 뒤에 / 로 감싸서 앞뒤로 덧붙여주어야 했다.
그랫더니 잘 데이터가 들어가는 것을 확인했다.
'프로젝트' 카테고리의 다른 글
포텐데이 비사이드 클로바ai 프로젝트 후기 (0) | 2023.12.18 |
---|---|
ec2 배포 time out 오류 해결 방법 (0) | 2023.12.15 |
ec2 서버 생성 및 환경 구축 할 때 찾은 레퍼런스 사이트 및 ec2 환경 구축 (0) | 2023.12.12 |
JPA 사용하여 Entitiy구성 중 날짜 자동 생성 오류 (0) | 2023.12.05 |
Json 에 입력한 값이 데이터베이스에 저장이 되지 않는 경우 (0) | 2023.12.03 |