본문 바로가기

Spring/스프링 입문12

[Spring] 2-2. MVC와 템플릿 엔진 MVC : Model, View, Controller Controller @Controller public class HelloController { @GetMapping("hello-mvc") public String helloMvc(@RequestParam("name") String name, Model model) { model.addAttribute("name", name); return "hello-template"; } } View resources/templates/hello-template.html hello! empty 실행 : http://localhost:8080/hello-mvc?name=spring MVC, 템플릿 엔진 이미지 https://www.inflearn.com/cours.. 2023. 10. 31.
[Spring] 2-1. 정적 컨텐츠 스프링 부트 정적 컨텐츠 기능 https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/spring-boot-features.html#boot-features-spring-mvc-static-content resources/static/hello-static.html 정적 컨텐츠 입니다. 실행 : http://localhost:8080/hello-static.html 정적 컨텐츠 이미지 https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81-%EC%9E%85%EB%AC%B8-%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8 [무료] 스프링 입문 - 코드로 .. 2023. 10. 31.
[Spring] 1-4. 빌드하고 실행하기 빌드하고 실행하기(windows) 콘솔로 이동 → 명령 프롬프트(cmd)로 이동 ./gradlew → gradlew.bat 실행 cmd에서 gradlew.bat를 실행하려면 gradlew하고 엔터 gradlew build cd ./build/libs java -jar hello-spring-0.0.1-SNAPSHOT.jar http://localhost:8080 확인 윈도우에서 Git bash 터미널 사용하기 링크 : https://www.inflearn.com/questions/53961 https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81-%EC%9E%85%EB%AC%B8-%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A.. 2023. 10. 30.
[Spring] 1-3. View 환경설정 Welcome Page 만들기 resources/static/index.html Hello hello 스프링 부트가 제공하는 Welcome Page 기능 static/index.html 을 올려두면 Welcome page 기능을 제공한다. https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/spring-boot-features.html#boot-features-spring-mvc-welcome-page thymeleaf 템플릿 엔진 thymeleaf 공식 사이트 : https://www.thymeleaf.org/ 스프링 공식 튜토리얼 : https://spring.io/guides/gs/serving-web-content/ 스프링 부.. 2023. 10. 30.
[Spring] 1-2. 라이브러리 살펴보기 Gradle은 의존관계가 있는 라이브러리를 함께 다운로드한다. 스프링 부트 라이브러리 spring-boot-starter-web spring-boot-starter-tomcat : 톰캣(웹 서버) spring-webmvc : 스프링 웹 MVC spring-boot-starter-thymeleaf : 타임리프 템플릿 엔진(View) spring-boot-starter(공통) : 스프링 부트 + 스프링 코어 + 로깅 spring-boot spring-core spring-boot-starter-logging logback, slf4j 테스트 라이브러리 spring-boot-starter-test junit : 테스트 프레임워크 mockito : 목 라이브러리 assertj : 테스트 코드를 좀 더 편하게 작.. 2023. 10. 30.
[Spring] 1-1. 프로젝트 생성 프로젝트 생성 사전 준비물 Java 11 설치 (인데 저는 Java 17을 사용하였습니다.) IDE : IntelliJ 또는 Eclipse 설치 (IntelliJ를 추천하셨습니다.) 스프링 부트 스타터 사이트로 이동해서 스프링 프로젝트 생성 https://start.spring.io/ 프로젝트 선택 Project : Gradle-Groovy Project Language : Java Spring Boot : 2.3.x (를 사용하라고 하셨지만 이는 강의 녹화 당시의 버전이고 저는 3.1.5를 사용하였습니다.) (*참고 : SNAPSHOT이나 M1 등이 붙어있는 것은 정식 버전이 아니기에 아무것도 붙어있지 않은 3.1.5를 선택함) Packaging : Jar Java : 11 (인데 저는 위랑 맞춰서 1.. 2023. 10. 29.