การตั้งค่าโปรเจกต์และการพึ่งพา
ตั้งค่าโปรเจกต์ Spring Boot ใหม่และผสานการพึ่งพา Spring Security ที่จำเป็นเพื่อสร้างสภาพแวดล้อมที่ปลอดภัย
การตั้งค่าโปรเจกต์และการพึ่งพา เป็นบทเรียน Spring Security 6 & JWT Authentication ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Spring Security 6 & JWT Authentication และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Spring Security 6 & JWT Authentication มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Ready for Secure Apps!
Let's get a real project ready. You'll spin up a Spring Boot app and pull in the dependencies that switch on Spring Security 6.
Creating a Spring Boot Project
Start fast with Spring Initializr at start.spring.io — a web wizard that generates your whole project structure and build files in seconds.
Initializr Basics
In Spring Initializr you pick the build (Maven), language (Java), a stable Boot version, and metadata like group and artifact. That defines your project skeleton.
What Are Dependencies?
Dependencies are external libraries your app pulls in for features it doesn't write itself — pre-built code you wire in instead of reinventing.
The Security Starter
One dependency unlocks it all: spring-boot-starter-security. This starter pulls in the core auth and authorization modules in a single line.
Web Application Needs
To serve HTTP, add spring-boot-starter-web. It bundles embedded Tomcat and Spring MVC so your app can handle web requests and API responses.
Maven: Your Project's Blueprint
With Maven, you declare every library in pom.xml — your project's blueprint inside a <dependencies> block that tells Maven what to fetch.
Adding Security to pom.xml
Here's how the two starters sit inside your pom.xml dependencies block. Initializr adds these automatically when you select them.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Other dependencies like spring-boot-starter-test... -->
</dependencies>First Run: What Happens?
Run the app with the security starter added and Spring Security locks every endpoint instantly. Watch the console for its generated default password.
package com.coddykit.securitysetup;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SecuritysetupApplication {
public static void main(String[] args) {
SpringApplication.run(SecuritysetupApplication.class, args);
System.out.println("\n--- Application Started --- ");
System.out.println("Check your console for a default password if you access the app.");
}
}Quick Check!
After adding spring-boot-starter-security to a new Spring Boot web project, what is the immediate default behavior when you try to access any endpoint in your browser?
Recap: Project Ready!
Recap: you scaffolded a project with Spring Initializr, added the web and security starters, and saw Boot hand you a login page and console password for free.
คำถามที่พบบ่อย
บทเรียน “การตั้งค่าโปรเจกต์และการพึ่งพา” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การตั้งค่าโปรเจกต์และการพึ่งพา” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Spring Security 6 & JWT Authentication ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Spring Security 6 & JWT Authentication มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การตั้งค่าโปรเจกต์และการพึ่งพา”
ตั้งค่าโปรเจกต์ Spring Boot ใหม่และผสานการพึ่งพา Spring Security ที่จำเป็นเพื่อสร้างสภาพแวดล้อมที่ปลอดภัย คุณปฏิบัติ Spring Security 6 & JWT Authentication ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Spring Security 6 & JWT Authentication หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Spring Security 6 & JWT Authentication บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “การตั้งค่าโปรเจกต์และการพึ่งพา” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Spring Security 6 & JWT Authentication นี้ได้ไหม
ได้ บทเรียน Spring Security 6 & JWT Authentication ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- บทนำสู่ Spring Security 6
- การตั้งค่าโปรเจกต์และการพึ่งพา
- การยืนยันตัวตนผู้ใช้ในหน่วยความจำ
- ทำความเข้าใจสายโซ่ตัวกรองของ Spring Security