개인과제로 Spring boot 로 개인 블로그 백엔드 만들기가 나왔다. 해결방법 보다는 문제 외 이슈사항이랑 참고용을 정리했다.
컬럼값과 들어갈 기능을 정리하고 기능별 (5개) api를 만들어 진행
java - com.sparta.blogserver 안에 패키지를 만들어 아래 파일들 저장
실행 순서는 controller -> Service -> repository -> DB 순으로 갔다가 다시 반대로 클라이언트한테 돌아감
파일 구분과 역할
-> Dto : 데이터 전송 및 이동을 위해 생성되는 객체를 의미(필드나 생성자가 들어감)
-> entity : DB 작업용 객체
-> Controller : API를 만들고 Service에 요청
-> Service : 실세, 행동을하고 데이터 변동이 있으면 Repository에 넘김
-> Repository : DB에서 데이터 가져오기, 수정, 삭제 등을 진행
Error
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
CREATE DATABASE 데이터명;
implementation 'mysql:mysql-connector-java:8.0.28'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
spring.datasource.url=jdbc:mysql://localhost:3306/{Database}
spring.datasource.username={User}
spring.datasource.password={pwd}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
IntelliJ 프로젝트 생성된 git을 github에 연결하는 방법을 헤매서 참고용으로 적어둔다.
github에 새로운 repositories 만들기!
Git -> Manage Remotes -> + -> URL에 위에서 만든 repositories URL 입력
-> Commit -> Push
git 계정 연동
File -> Settigs... -> Version Control -> GitHub -> +버튼 클릭 -> Log In via GitHub...
JetBrain 웹페이지에서 Authorize in GitHub 버튼 -> 로그인 -> IntelliJ 팝업에서 OK
GitHub Repository 생성 및 업로드
Git -> GitHub -> Share Project on GitHub -> Share
위 처럼 진행하면 프로젝트명으로 repository가 하나 생성됨