본문 바로가기

Framekwork50

[자바/스프링] API (getter, setter, json) 💾 main > java > hello > hellospring > controller > HelloSpringApplication package hello.hellospring.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @Controller public.. 2023. 2. 14.
[자바/스프링] 정적 컨텐츠 (static) 스프링 웹 개발 기초 정적 컨텐츠 파일을 웹 브라우저에 그대로 내려주는 거 MVC와 템플릿 엔진 JSP나 PHP가 템플릿 엔진임. html을 그냥 주는 게 아니라 서버에서 프로그래밍을 해서 html을 동적으로 바꿔서 내리는 거 model-view-controller 패턴으로 개발을 함 API JSON 포맷으로 클라이언트에게 데이터를 전달 서버끼리 통신할 때 활용 ✔️ 정적 컨텐츠와 MVC/템플릿 엔진의 차이는! 정적 컨텐츠는 웹 페이지에 파일을 그대로 내려주는 거 MVC/템플릿 엔진은 서버에서 변형을 해서 내려주는 거 정적 컨텐츠 https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.stati.. 2023. 2. 12.
[자바/스프링] 빌드하고 실행하기 (윈도우) ✔️ 콘솔로 이동 `./gradlew build` `cd build/libs` `java -jar hello-spriong-0.0.1-SNAPSHOP.jar` 실행 확인 윈도우에서 빌드하고 실행하기 0. windows + R 실행 > cmd > 확인 1. C:\Users>F: 폴더가 F드라이브에 있어서 우선 F 드라이브로 이동을 했다. cd가 아니라 F: 이 형태로 적어야, 그 드라이브로 이동을 한다. 2. F:\>cd hello-spring `hello-spring` 폴더로 이동 3. F:\hello-spring>gradlew.bat build (윈도우의 경우) gradlew.bat build 로 설치 `BUILD SUCCESSFUL` 문구를 확인하면 성공! build 폴더가 생성됨 4. F:\hell.. 2023. 2. 11.
[자바/스프링] `spring-boot-devtools` 라이브러리 추가 ✔️ `spring-boot-devtools` 라이브러리를 추가하면, `html` 파일을 컴파일만 해주면 서버 재시작 없이 View 파일 변경 가능 💾 build.gradle dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-devtools' // 추가 testImplementation 'org.springframework.boot:spring-boot-starter-test' } ✔️ Fi.. 2023. 2. 10.
[자바/스프링] View 환경설정 (add. thymeleaf ) ✔️ 스프링 부트가 제공하는 Welcome Page 기능 static/index.html 을 올려두면 Welcome page 기능을 제공함 💾 resources/static/index.html Hello hello ✔️ thymeleaf 템플릿 엔진 thymeleaf 공식 사이트: https://www.thymeleaf.org/ 스프링 공식 튜토리얼: https://www.thymeleaf.org/ 스프링부트 매뉴얼: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.spring-application 💾 main > java > hello > hellospring > controller > HelloControll.. 2023. 2. 9.
[자바/스프링] 라이브러리 Gradle이나 Maven과 같은 build 툴들은 의존관계를 관리해준다. Gradle은 의존관계가 있는 라이브러리를 함께 다운로드 한다. 인텔리제이 우측 Gradle 버튼을 클릭한 후, [hello-spring > Dependencies > compileClasspath]에서 의존 관계를 확인할 수 있다. ✔️ 스프링 부트 라이브러리 spring-boot-starter-web spring-boot-starter-tomcat: 톰캣 (웹서버) spring-webmvc: 스프링 웹 MVC spring-boot-starter-thymeleaf: 타임리프 템플릿 엔진(View) spring-boot-starter(공통): 스프링부트 + 스프링 코어 + 로깅 spring-boot spring-core sprin.. 2023. 2. 8.