รับทําเว็บไซต์ รับทําseo
บทความที่น่าสนใจ

บทความ ที่น่าสนใจ

การพัฒนา Java Project ด้วย Spring Boot ตอนที่ 2 - ติตตั้ง Spring Tool Suite (STS) บน Eclipse IDE

    ในการพัฒนา Spring Application มักจะนิยมใช้ Eclipse ในการพัฒนา โดยจะใช้ Add On ตัว Spring Tool Suite (STS) บน Eclipse เพื่อใช้สำหรับพัฒนา Spring Application ได้ง่ายขึ้น

    ขั้นตอนติตตั้ง Spring Tool Suite (STS) บน Eclipse IDE
    1. เปิด Eclipse และไปยัง market place
    2. ให้ค้นหาคำว่า sts
    3. ยืนยัน package
    4. ยืนยัน license
    5. restart eclipse เมื่อ report เปิดขึ้นมาใหม่ จะเห็น spring framework
    6. เปลี่ยน perspective เลือก spring
    7. สร้าง spring boot project
    8. ใส่ข้อมูล application
    9. จะได้ตัวโปรเจค

    ไฟล์ pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>net.itbakery</groupId>
        <artifactId>HelloSpringBoot</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
        <name>HelloSpringBoot</name>
        <description>Demo project for Spring Boot</description>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.0.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
             <dependency>
                       <groupId>org.springframework.boot</groupId>
                       <artifactId>spring-boot-starter-web</artifactId>
             </dependency>
            <dependency>
                <groupId>net.bytebuddy</groupId>
                <artifactId>byte-buddy-dep</artifactId>
                <version>1.8.0</version>
            </dependency>  
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </project>

    ไฟล์ HelloSpringBootApplication.java
    package net.itbakery.hellospringboot;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    @SpringBootApplication
    public class HelloSpringBootApplication {
        public static void main(String[] args) {
            SpringApplication.run(HelloSpringBootApplication.class, args);
        }
    }
    @RestController
    class GreetingController {
        @RequestMapping("/hello/{name}")
        String hello(@PathVariable String name) {
            return "Hello, " + name + "!";
        }
    }

    10. build dependency
    $ cd /path/HelloSpringBoot
    $ mvn dependency:tree


    11). Run Spring
    $ mvn spring-boot:run

บทความที่น่าสนใจ

บทความ ล่าสุด

บทความ ความรู้ด้านไอที, คอมพิวเตอร์ Techonlogy, Gadget, ความรู้เกี่ยวกับคอมพิวเตอร์ กับทาง SoftMelt.com