-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
3.0 버전 업데이트 되면서 의존성 관련해서 뭔가 많이 바뀌었는데
스프링부트 3.1에서는 h2 2.1.214 버전을 써야하는 걸로 알고 있습니다.
H2 버전 관련 부분은 이 분의 블로그를 참고했습니다.
https://velog.io/@gmtmoney2357/스프링-부트-3.0에서-h2-console-404-에러
이 부분에서 문제가 발생 👇
alter table Taco_Ingredients
add foreign key (ingredient) references Ingredient(id);
처음 스프링 시작할 때 jdbcsqlsyntaxerrorexception: constraint "primary key | unique (id)" not found; 에러가 발생했는데요.
외래키로 거는 컬럼이 unique하지 않으면 외래키 제약 조건 추가가 안되는 것 같습니다.
이전 코드
create table if not exists Ingredient (
id varchar(4) not null,
name varchar(25) not null,
type varchar(10) not null
);
수정 코드
create table if not exists Ingredient (
id varchar(4) PRIMARY KEY not null,
name varchar(25) not null,
type varchar(10) not null
);
PRIMARY KEY를 추가해주니 잘 되는 거 같습니다.
Metadata
Metadata
Assignees
Labels
No labels