Spring Boot

Spring Boot เป็น project นึงของ Spring Framework ที่ทำให้พัฒนา Application ได้รวดเร็วโดยที่มีการทำ Auto Configuration ทำให้ไม่ต้องเสียเวลาไป Config ทุกอย่างเองเหมือนแต่ก่อน เราสามารถสร้าง standalone application ที่ export เป็น jar หรือจะทำเป็น war แล้วนำไป deploy ที่ application server เหมือนเดิมก็ได้

Spring Boot ก็คือ Spring ที่ผ่านการ Upgrade แล้วโดยเราจะไม่มองมันเป็น App แต่เราจะมองมันเป็น Service เหมือน Service ใน Linux ก็คือ มันสามารถรันได้ด้วยตัวมันเอง หรือก็คือมัน Built in Server มาให้ในตัวแล้ว เอาไปใช้ได้เลย เวลา Server มีปัญหาก็ไม่กระทบต่อ Service ทั้งหมด ทำให้เวลาไปใช้งานจริง Spring Boot จะใช้ง่าย และ เหมาะแก่การเอามาใช้ในโปรเจคมากกว่าครับ

มี Features อะไรบ้าง

  • สร้างเป็น standalone spring application มี main method
  • มี embed container (tomcat, jetty, undertow)  ปกติจะเป็น tomcat แต่สามารถเลือกเป็นตัวอื่นได้
  • มี POM ‘starter’ ที่เตรียมมาให้พร้อมใช้งาน ไม่ต้องกังวลเรื่อง dependency ให้ปวดหัว
  • Auto Configuration ทำให้ไม่ได้ configuration มากเหมือนแต่ก่อน
  • เตรียม feature สำหรับ monitoring เพื่อดู memory , thread, metrics
  • ไม่จำเป็นต้องมี XML configuration อีกต่อไปเพราะทุกอย่างเขียนเป็น Java-based Configuration

Servlet container support

Spring boot สามารถทำงานกับ servlet container หลายตัวเช่น tomcat, jetty, undertow

Name Servlet Version Java Version
Tomcat 8 3.1 Java 7+
Tomcat 7 3.0 Java 6+
Jetty 9 3.1 Java 7+
Jetty 8 3.0 Java 6+
Undertow 1.1 3.1 Java 7+

Template Engine Support

Spring boot จะ auto configuration สำหรับ template engine หลายตัว

  • FreeMarker
  • Groovy
  • Thymeleaf
  • Velocity
  • Mustache

Caching Support

ตั้งแต่ spring boot เวอร์ชั่น 1.3 จะ auto configuration โดย support caching technologies หลายตัวเช่น

  • EhCache
  • hazelcast
  • Guava
  • Simple Map based in-memory cache

Spring boot เป็นเครื่องมือที่ทำให้ Developer สามารถใช้งาน Spring Framework ได้ง่ายและรวดเร็ว ลดขึ้นตอนการ configuration ด้วยวิธีการทำ Auto Configuration นั่นเอง

สามารถหาข้อมูลเพิ่มเติมได้ที่ spring.io
ใครอยากจะลองสร้าง Spring Project ก็ไปลองกันได้ ที่นี่ เลย

cr. [1] [2]