5. 스프링부트 기반 웹 프로젝트 구성

kdew0308·2023년 3월 10일
0

학습 관리 시스템

목록 보기
5/17
post-thumbnail

1. 프로젝트 생성

2. 툴 튜닝

  1. view -> apperance -> Toolbar
  2. view -> apperance -> details in treeview
  3. Setting -> wheel검색 -> Change font size with Ctrl+Mouse Wheel in: 클릭

3.프로젝트 실행

3-1) 에러 발생

Compilation of Maven projects is supported only if external build is started from an IDE

해결

pom.xml을 마우스 오른쪽 버튼으로 클릭한 다음 Maven 프로젝트로 추가를 클릭

3-2) 에러 발생

warning: source release 17 requires target release 17
본 프로젝트는 Java8로 버전으로 작업되었으나, Java17을 참조하려고 해서 일어나는 에러

해결

결국 프로젝트 다시 생성

4. 컨트롤러 생성

@RestController
public class IndexController {

    
    public String index() {
        return "Hello !!!";
    }
}

funtion만 가지고는 매핑되는게 의미가 없음
기본적으로 Controller는 주소가 있아야됨!

@RestController
public class IndexController {

    @GetMapping("/")
    public String index() {
        return "Hello !!!";
    }
}

그래서 GetMapping 추가!

  • @RestController : 이게 있어야 컨트롤인거를 약속한것임
  • @GetMapping : 웹에 매핑하기 위해 필요, 해당 주소에 매핑되는 것임

5. 데이터베이스 추가


Database 클릭 -> + 클릭 -> Data Source -> MariDB 클릭 -> 정보 입력

0개의 댓글

관련 채용 정보