package com.rubypaaper.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController // 스프링 4에서 부터 지원하는 컨트롤
public class BoardController {
public BoardController() {
System.out.println("===>BoardController 생성하기 ");
}
@GetMapping("hello")
public String hello( String name ) {
return "HELLO : " + name;
}
}
@SpringBootApplication 에 스캐너가 기본적으로 들어있다.
package com.rubypaaper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"com.ruby","com.rubypaaper"})
public class Chapter01Application {
public static void main(String[] args) {
SpringApplication application =
new SpringApplication(Chapter01Application.class);
application.setWebApplicationType(WebApplicationType.SERVLET);
application.run(args);
}
}