์ด๋ฒ์ ๋ง๋ค ์น์ฌ์ดํธ๋
vue.js๋ฅผ ์ฌ์ฉํ ๊ฒ์ด๋ค
๐
1. ๋ง๋ค๊ณ ์ ํ๋ ๊ฒ์?
ํ์๊ฐ์
์น์ฌ์ดํธ๋ฅผ ๋ง๋ค๊ณ ์ ํ๋ค. Vue.js๋ฅผ ์ฌ์ฉํ์ฌ ํ๋ก ํธ ๊ณต๋ถ๋ฅผ ํ๋ฉด์, ๊ฐ๋จํ ํ์๊ฐ์
๊ณผ ๋ก๊ทธ์ธ์ ์ํํ๋ ์น์ฌ์ดํธ๋ฅผ ๋ง๋ค ๊ฒ์ด๋ค. ๋๋ถ๋ถ์ ์น์ฌ์ดํธ์ ํ์๊ฐ์
๊ณผ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ํ์ํ๋ ๋ค๋ฅธ ํ๋ก์ ํธ๋ฅผ ํ๊ฒ ๋ผ๋ ๋ฏธ๋ฆฌ ๋ง๋ค์ด๋๋ฉด ํธ๋ฆฌํ ๊ฒ ๊ฐ๋ค.
๊ฐํธ ๋ก๊ทธ์ธ, ํ์๊ฐ์ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ๊ฒ์ด ์ด๋ฒ ํ๋ก์ ํธ์ ๋ชฉํ์ด๋ฉฐ, Vue์ ์ฌ์ฉ ๋ฐฉ๋ฒ์ ํฐ๋ํ๊ณ ์ด๋ป๊ฒ ํ๋ฌ๊ฐ๋์ง ํ์ ํ๊ณ ์ ํ๋ค.


2. Spring initializr ์์ฑํ๊ธฐ.
โก dependencies ์ค์ ํ๊ธฐ.

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
- implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
: @Entity, @Repository ๋ฑ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ด๋ฆฌ๋ฅผ ํธ๋ฆฌํ๊ฒ ํด์ค๋ค. - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
: ์นด์นด์คํก, ๊ตฌ๊ธ๋ก ๊ฐํธํ๊ฒ ๋ก๊ทธ์ธํ๋ ์์ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ด๋ค.
- implementation 'org.springframework.boot:spring-boot-starter-security'
: ์ธ์ฆ๊ณผ ๊ถํ ๋ฑ ๋ณด์ ๊ด๋ฆฌ ๋ด๋นํ๋ค. - implementation 'org.springframework.boot:spring-boot-starter-validation'
: @Email, @NotNull ๋ฑ ์ ๋ ฅ๊ฐ์ ๊ฒ์ฆ์ ํธ๋ฆฌํ๊ฒ ํด ์ค๋ค. - implementation 'org.springframework.boot:spring-boot-starter-web'
: ๋ด์ฅ๋ ํฐ์ผ ์๋ฒ, ์ปจํธ๋กค๋ฌ ๋ฑ web์ ๊ฐ๋ฐํ๊ธฐ ์ํด ํธ๋ฆฌํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค. - compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
: ๋กฌ๋ณต ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก @Getter, @Setter ๋ฑ ์ฝ๋ ์์ ์ค์ด๋๋ฐ ๋์์ ์ค๋ค. - developmentOnly 'org.springframework.boot:spring-boot-devtools'
: ์ฝ๋๋ฅผ ์์ ํ๋ฉด ์๋์ผ๋ก ๋ฆฌ๋ก๋๋ฅผ ํด์ฃผ๋ ๋ฑ ํธ๋ฆฌ๋ฅผ ์ ๊ณตํ๋ค. - runtimeOnly 'com.h2database:h2'
: ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ h2๋ก ์ฌ์ฉํ ๊ฒฝ์ฐ ์ ํํ๋ค.
โก Java ๋ฒ์ ์ ํํ๊ธฐ
โ๏ธ [Mac ๊ธฐ์ค] ์๋ฐ ๋ฒ์ ์ ์ ๋ชจ๋ฅด๊ฒ ๋ค๋ฉด?

- ํฐ๋ฏธ๋์ ๋ค์ด๊ฐ๋ค.
- ํฐ๋ฏธ๋์ java --version์ด๋ผ๊ณ ์น๋ฉด ๋๋ค.
โธ openjdk 17.0.11์ผ๋ก ํ์ธ๋๋ค. - ๋ง์ฝ ์ ๋ฌ๋ค๋ฉด java ์ค์น๊ฐ ์๋์ด์์ผ๋, ์ค์นํฉ์๋ค.
โก ์ฌ์ฉ์ ์ค์ ํ๊ธฐ

spring.application.name=JoinWeb
// ์ถ๊ฐํด์ฃผ๊ธฐ
spring.security.user.name=sori
spring.security.user.password=1234
๋ณธ์ธ์ด ์ํ๋ ์ด๋ฆ๊ณผ ํจ์ค์๋๋ฅผ ์์ฑํฉ๋๋ค.
โก ๊ฐ๋จํ๊ฒ ํ๋ฉด์ hello, join-web ์ถ๋ ฅ
@RestController
public class Hello {
@GetMapping("/hello")
public String helloWorld() {
return "hello, join-web";
}
}
โก http://localhost:8080/hello ๋ค์ด๊ฐ๊ธฐ
- ์ฒ์์ ์์ ๊ฒฝ๋ก๋ก ๋ค์ด๊ฐ๋ฉด /login์ผ๋ก url์ด ๋ณ๊ฒฝ๋๋ฉด์ ์๋์ ๊ฐ์ ํ๋ฉด์ด ๋์จ๋ค.

- dependencies์ security๋ฅผ ๋ฃ์ด์ ๊ทธ๋ฐ ๊ฑฐ๋, ์์ ์๋ ์ฌ์ฉ์ ์ค์ ํ๊ธฐ์์ ์ด๋ฆ๊ณผ ํจ๋์๋๋ฅผ ๋ฃ์ด๋จ๋ ์ ๋ณด๋๋ก ์ ๋ ฅํด ์ฃผ๋ฉด ์ ๋๋ก ์ถ๋ ฅ๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

- ์ํฐ๋ฅผ ๋๋ฅด๋ฉด /hello๋ก ๋ค์ด๊ฐ์ง๋ค.

3. Vue.js ์ค์นํ๊ธฐ.
โก Node.js ์ค์นํ๊ธฐ
https://nodejs.org/ko
Node.js — Run JavaScript Everywhere
Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
nodejs.org
โก ์ค์น ํ ํฐ๋ฏธ๋์์ npm -v๋ก ํ์ธํ๊ธฐ
โก npm create vue@latest -> y๋ฅผ ๋๋ฅด๋ฉด ์ค์น๋ฅผ ์์ํ๋ค.

โก ์ค์ ํ๊ธฐ
- Project name : ํ๋ก์ ํธ ์ด๋ฆ ์ค์
์ฌ๊ธฐ์ vue-project๋ผ๊ณ ํ๋๋ฐ, ๋์ค์ ์์ ํ์ต๋๋ค.
์์ ๋ฐฉ๋ฒ์ mv vue-project join-web์ผ๋ก mv ์๋์ด๋ฆ ๋ณ๊ฒฝ์ด๋ฆ์ ํ์์ผ๋ก ์ฐ๋ฉด ๋ฉ๋๋ค. - Select features to include in your project : ํ๋ก์ ํธ์ ์ถ๊ฐํ๊ณ ์ถ์ ๊ธฐ๋ฅ
๋ฐฉํฅํค๊ณ ์ด๋ํ์๊ณ , ์คํ์ด์ค๋ฐ๋ก ์ ํ/ํด์ ํ์ธ์. - Select experimental features to include in your project: ์คํ์ ์ธ ๊ธฐ๋ฅ
์ ํํ์ง ์๊ณ ๋์ด๊ฐ๋๋ค.

โก ์คํํ๊ธฐ
- cd join-web ๋ง๋ ํ๋ก์ ํธ๋ก ์ด๋ํ๊ธฐ.
- npm install ์์กด์ฑ ์ค์นํ๊ธฐ.
- npm run dev ๊ฐ๋ฐ ์๋ฒ ์คํํ๊ธฐ.
- http://localhost:5173/ ๋ก ๋ค์ด๊ฐ์ ํ์ธํ๊ธฐ.


