= Spring = Spring helps development teams everywhere build simple, portable, fast and flexible JVM-based systems and applications. == REST service == spring.io/guides/gs/rest-service/ * mkdir -p /tmp/greetingSpring * mkdir -p /tmp/greetingSpring/src/main/java/hello * mkdir -p /tmp/greetingSpring/target * cd /tmp/greetingSpring pom.xml {{{ 4.0.0 org.springframework gs-rest-service 0.1.0 org.springframework.boot spring-boot-starter-parent 1.1.5.RELEASE org.springframework.boot spring-boot-starter-web hello.Application maven-compiler-plugin 2.3.2 org.springframework.boot spring-boot-maven-plugin spring-releases http://repo.spring.io/libs-release spring-releases http://repo.spring.io/libs-release }}} src/main/java/hello/Application.java {{{ package hello; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } }}} src/main/java/hello/Greeting.java {{{ package hello; public class Greeting { private final long id; private final String content; public Greeting(long id, String content) { this.id = id; this.content = content; } public long getId() { return id; } public String getContent() { return content; } } }}} src/main/java/hello/GreetingController.java {{{ package hello; import java.util.concurrent.atomic.AtomicLong; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); @RequestMapping("/greeting") public Greeting greeting(@RequestParam(value="name", required=false, defaultValue="World") String name) { return new Greeting(counter.incrementAndGet(), String.format(template, name)); } } }}}