Back end
-
테스트 작성하기Back end/SpringBoot 2023. 12. 12. 12:41
스프링 부트에서의 테스트는 소프트웨어 애플리케이션의 품질을 보장하고 코드의 정확성을 검증하기 위한 활동입니다. 테스트는 주로 두 가지 유형으로 나눌 수 있습니다: 단위 테스트(Unit Test)와 통합 테스트(Integration Test). 1. **단위 테스트(Unit Test):** - 개별적인 코드 블록 또는 모듈이 예상대로 작동하는지 확인하는 테스트입니다. - 주로 JUnit, TestNG 등의 테스트 프레임워크를 사용하여 작성됩니다. - 스프링 부트에서는 주로 서비스(Service), 리포지토리(Repository), 컨트롤러(Controller) 등의 각 컴포넌트에 대한 단위 테스트를 작성합니다. - 목 객체(Mock Object)를 사용하여 외부 의존성을 대체하여 테스트의 격리성을 유지합니..
-
-
HTTP와 RestControllerBack end/SpringBoot 2023. 12. 8. 12:36
- Controller RestController Controller는 일반 페이지를 retrun 하는 반면 RestController는 json과 return하는 text 즉 data를 반환한다. 예시 코드!! package com.example.firstproject.api; import com.example.firstproject.dto.ArticleForm; import com.example.firstproject.entity.Article; import com.example.firstproject.repository.ArticleRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.fac..
-
회원가입 -> 로그인 -> 조회 (~ crud 진행중)Back end/Spring MVC 2023. 12. 6. 18:37
crud 흐름을 정리 해보겠다. 그냥 학습하고 내 생각을 정리해서 적음 1. Project 셋팅 InteliJ , Mysql, mybatis, tomcat, jdk 18 사용 했음. 2. 회원가입 (controller -> (DTO) -> Service -> Repository 연결 ) - JSP -> Action,Method 값 설정 -> Controller에 보냄 -> url연결 :GetMapping, - 정보 전송(method:post): PostMapping 으로 전달 -> memberDTO 에 데이터(HTML의 name) 값들을 생성자(getter,setter) 및 tostring 값으로 설정 -> Controller의 POST 쪽에 데이터를 받아올@modelAttribute(MemberDTO ..
-
HttpSession 이란?Back end/Spring MVC 2023. 11. 30. 19:27
스프링 학습을 하면서 자세한 HttpSession이 궁금해짐 주로 로그인 기능을 설정할때 쓰는듯? HttpSession은 Java 웹 응용 프로그램에서 사용자 간의 상태 정보를 유지하고 관리하기 위한 인터페이스입니다. HTTP 프로토콜은 기본적으로 상태를 유지하지 않기 때문에, 각각의 HTTP 요청은 독립적이며 이전 요청과 상관이 없습니다. 이 때문에 사용자의 세션 상태를 유지하려면 추가적인 메커니즘이 필요합니다. HttpSession은 클라이언트와 서버 간의 지속적인 상태 유지를 지원하기 위해 사용됩니다. 주로 다음과 같은 상황에서 활용됩니다: 사용자 인증과 관련된 정보 유지: 로그인한 사용자의 정보를 세션에 저장하여 여러 페이지 간에 인증 정보를 공유할 수 있습니다. 장바구니와 같은 임시 데이터 저장..
-
폼 데이터 주고 받기Back end/SpringBoot 2023. 11. 29. 14:59
{{>layouts/header}} 제목 내용 Submit {{>layouts/footer}} => new 라는 전송폼을 만들어 주고 controller에 전달하기 위해 action값 및 method값 설정 @PostMapping("articles/create") public String createArticle(ArticleForm form){ // DTO의 AriticleForm으로 전달 System.out.println(form.toString()); return""; => getmapping이 아닌 postmapping 값으로 DTO의 폼으로 전달하기, system.out의 form.toString으로 전달 값 잘 전달 되었는지 확인하기 package com.example.fir..
-
뷰 템플릿과 MVC 패턴Back end/SpringBoot 2023. 11. 29. 13:15
- MVC 패턴 (Model-View-Controller): MVC는 소프트웨어 디자인 패턴으로, 소프트웨어를 세 가지 구성 요소로 분리하여 개발하는 방법론입니다. 각 구성 요소는 다음과 같습니다: 1. Model (모델):** 데이터와 비즈니스 로직을 담당합니다. 데이터의 상태를 유지하고, 변경에 따라 뷰와 컨트롤러에 통지합니다. 2. View (뷰):** 사용자 인터페이스와 관련이 있습니다. 모델의 데이터를 표시하고 사용자의 입력을 받아 컨트롤러에 전달합니다. 3. Controller (컨트롤러):** 사용자의 입력을 받아 모델과 뷰를 업데이트합니다. 모델의 상태를 변경하고, 이 변경을 뷰에 알리는 역할을 합니다. 이렇게 구성된 MVC 패턴은 소프트웨어의 유지보수성과 확장성을 높일 수 있습니다. - ..
-
스프링 프레임워크를 이해하기 위한 요소들Back end/Spring MVC 2023. 11. 24. 10:50
- 스프링 프레임워크를 잘 다루기 위해서는 여러 가지 측면에서 중요한 요소들이 있습니다. 아래는 스프링을 효과적으로 사용하기 위한 핵심 요소들입니다: 최신 버전의 스프링 학습: 스프링은 지속적으로 업데이트되고 발전하고 있습니다. 최신 버전의 스프링 프레임워크에 대한 이해와 활용은 새로운 기능과 최적화를 활용하는 데 중요합니다. 의존성 주입(Dependency Injection) 및 제어 역전(Inversion of Control) 이해: 스프링의 핵심 개념 중 하나는 의존성 주입과 제어 역전입니다. 이를 이해하고 활용하면 유지보수가 쉬우며 테스트하기 쉬운 코드를 작성할 수 있습니다. IoC 컨테이너 이해: 스프링은 IoC 컨테이너를 제공하여 객체의 생명주기와 의존성 관리를 자동으로 처리합니다. IoC 컨..