2021-08-05
This commit is contained in:
27
restful/build.gradle.kts
Normal file
27
restful/build.gradle.kts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Spring-boot Examples
|
||||
*
|
||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("elex-spring-boot")
|
||||
|
||||
id("org.springframework.boot") version "2.5.3"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-mustache")
|
||||
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
}
|
||||
13
restful/src/main/java/kr/pe/elex/examples/Application.java
Normal file
13
restful/src/main/java/kr/pe/elex/examples/Application.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class MainController {
|
||||
|
||||
@GetMapping(path = "/{name}", produces = {MimeTypeUtils.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<Person> home(@PathVariable String name) {
|
||||
|
||||
return ResponseEntity
|
||||
.ok(new Person(name, new Random().nextInt()));
|
||||
}
|
||||
}
|
||||
14
restful/src/main/java/kr/pe/elex/examples/Person.java
Normal file
14
restful/src/main/java/kr/pe/elex/examples/Person.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package kr.pe.elex.examples;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Person {
|
||||
@JsonProperty
|
||||
private String name;
|
||||
@JsonProperty
|
||||
private int age;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package kr.pe.elex.examples;
|
||||
1
restful/src/main/resources/application.properties
Normal file
1
restful/src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user