特に実用性とかは考えていない。何となくやってみたというだけ。
動かしたいやつ
1
2
3
4
5
6
7
8
9
|
@RestController
@RequestMapping("/")
public class MyController {
@GetMapping("/")
public String index() {
return "hello";
}
}
|
設定
1
2
3
4
5
6
7
8
9
10
11
12
|
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@Configuration
@EnableWebMvc
public class WebConfig {
@Bean
ServletWebServerFactory servletWebServerFactory() {
return new TomcatServletWebServerFactory(8080);
}
@Bean
DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
}
|
1
2
3
4
5
6
|
@ComponentScan
public class MyApplication {
public static void main(final String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
|