티스토리 뷰
728x90
출처
- [스프링부트 4] Spring MVC Controller 만들기 1탄 - 내. 일. 을 바꾸는 업무 자동화
- [SpringBoot] 스프링부트를 사용해서 웹 서버 기본 틀 만들기 - 밥대장
Maven pom.xml 설정
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>3.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>9.0.31</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Spring Boot main 소스
Spring Boot main 소스 하위 패키지만 자동으로 로딩(Controller, Service)
package com.bluexmas;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
//@ComponentScan(basePackages = {"com.bluexmas.controller"})
public class BluexmasApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(BluexmasApplication.class, args);
}
}
Controller 소스
package com.bluexmas.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class SampleController {
@ResponseBody
@RequestMapping("/sample")
public String sample() {
String data = "@ResponseBody 어노테이션을 통해 반환";
return data;
}
}
실행
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 튜닝쇼 2008
- Delphi Tip
- Linux
- 일본여행
- 동경
- KOBA
- MySQL
- 서울오토살롱
- Spring
- ffmpeg
- sas2009
- 전예희
- 송주경
- ubuntu
- Spring MVC
- flex
- Xcode
- Delphi
- ble
- Mac
- oracle
- 레이싱모델 익스트림 포토 페스티벌
- 지스타2007
- koba2010
- Java
- JavaScript
- BPI-M4
- android
- NDK
- SAS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함