Spring Boot Super Beginner Guide Part 3 ได้เวลาของDependency!

Rahat Sarawasee
Nov 7 · 1 min read
Image by Karin Laurila from Pixabay

Dependency คืออะไร??

อธิบายแบบเห็นภาพง่ายๆ ถ้าเปรียบ Spring Boot เป็นรถยนต์เดิมๆที่ไม่มีอะไรแต่ง Dependency ก็คงจะเป็น ล้อ ท่อ สปอยเลอร์ หรืออะไรก็แล้วแต่ ที่ทำให้รถของคุณมี option มากขึ้นถ้าแต่งดีๆรถของคุณก็จะแรงและเท่ขึ้น! แต่ถ้าแต่งไม่ดีก็อาจจะช้าลงก็ได้นะ อิอิ

แล้วมันใช้ยังไงอ่ะไอDependency เนี่ย??

ย้อนกลับไปพาร์ทก่อน จิ้มๆ ตอนที่เรา Generate Project Spring Boot ของเราเนี่ยด้านล่างมันจะคำว่า Dependencies อยู่!

เห็น Dependencies ไหม?

ทีนี้ในช่อง search เนี่ยเราจะสามาหารหา dependency ต่างๆที่ทาง Spring boot เขา provide มาให้ได้แล้ว โดยในตอนนี้เนี้ยเราจะใช้ dependency ตามนี้!

และเมื่อเราทำการ Generate Project ขึ้นมาแล้ว ลองไปดูที่ไฟล์ pom.xml ดูซิ!

pom.xml

จะพบว่า Dependency ที่เราจิ้มมาเนี่ยจะมาถูกใส่ไว้ใน pom.xml ลองไล่ๆอ่านชื่อมันเอาดูนะ เดี๋ยวในพาร์ทต่อๆไปจะมาสอนว่า Dependency แต่ละตัวใช้ยังไงนะ :) ตอนนี้ลองใส่ dependency แต่ละตัวแล้วลองไล่ชื่อดูว่ามันอยู่ใน pom ของเราหรือป่าวแล้วเจอกันพาร์ทหน้า :)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade