Test1.java
package com.example.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Test1 {
@GetMapping("/test1")
public String write1() {
return "Hello World1";
}
}
RestControllerはメソッドの戻り値を画面に表示する
@GetMappingは@RequestMapping(method=RequestMethod.GET)と同じ意味
Run As -> Spring boot
http://localhost:8080/test1
Hello World1
application.properties
server.port=8756
pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>true</scope> </dependency>
spring-boot-devtoolsをtrueにするとファイルを更新した際に、アプリを再起動しなくても更新される。