[스프링부트 블로그 프로젝트] 4, 5, 6, 7, 8, 9강

오젼·2024년 1월 25일
0

4강 프로젝트 실행해보기

패키지를 만들 땐 처음에 만든 패키지 이하에 새 패키지를 만들어 줘야 함
ex) com.cos.blog를 처음에 만들고 시작했으니
com.cos.blog.test (O)
com.cos.test (X)

@Controller

스프링이 com.cos.blog 패키지 이하를 스캔해서 모든 파일을 메모리에 new 하는 것이 아니라
특정 어노테이션이 붙어 있는 클래스 파일들을 new해서(IoC) 스프링 컨테이너에 관리해준다.

error

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

에러 났었는데 일단 강의 보고
1. pom.xml에서 jpa 디펜던시 주석 처리 함

근데 해결 안 됨 그래서

  1. jdbc mysql 연동 함. 아래 페이지에서 연동 부분까지 따라함.
    https://wisdom-and-record.tistory.com/61

이래도 해결 안 돼서 끄고 낼 다시 해야지 하고 강제종료 했다 다시 들어갔는데 해결 됐다..
뭘로 해결 된 건진 잘 모르겠음

어쨌든 저 에러가 db연결이 안 돼서 나온 거란 건 알게 됐다.

그리고 에러 자꾸 해결 안 될 때 걍 강제종료 해보기;; 역시 만병통치약 강제종료 재부팅

테스트 화면

5강 MySQL 환경세팅

https://getinthere.tistory.com/17

MySQL Workbench 실행

root 커넥션 만들어 주기

사용자 생성 및 권한 주기 및 DB 생성

!! command + enter 누르면 쿼리 실행 되는데
커서가 있는 한 줄만 실행 되는 거다

모든 쿼리 실행시키는 건 shift + command + enter
ㅇㄴ 어쩐지 데이터베이스만 만들어졌더라;;

MySQL 한글 설정

/opt/homebrew/etc/my.cnf 경로로 들어가기

# Default Homebrew MySQL server config
[mysqld]

# Only allow connections from localhost
bind-address = 127.0.0.1

# jsp blog 한글 설정
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
init_connect='SET collation_connection = utf8_general_ci'
character-set-server=utf8

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

pom.xml 주석 해제

jpa, mysql dependency 주석 해놨던 것 다시 풀기

그럼 에러나는데 MySQL 이랑 스프링 연결을 해줘야 해서 그럼

6강 MySQL 스프링 연결

applicaion.properties 수정

application.properties -> application.yml 로 파일 확장자 바꾸기

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/blog?serverTimezone=Asia/Seoul
    username: cos
    password: cos12345

7, 8, 9강 Git 관련 내용. 건너뛰기

0개의 댓글