Back-End/Java Spring Boot

스프링 빈의 의존관계 방법은 두가지가 존재한다 컴포넌트 스캔과 자동 의존 관계 설정 자바 코드로 직접 스프링 빈 등록하기( = 설정 파일에 직접 빈을 등록하는 방법) 각 방법별로 어떻게 스프링 빈을 설정하는지 살펴보자 컴포넌트 스캔과 자동 의존관계 설정 컴포넌트 스캔의 정의는 @Component를 가진 모든 대상을 가져와 빈에 등록하기 위해 찾는 과정을 의미한다. 아래와 같은 MemberController 컨트롤러 클래스가 있다고 가정하자 package hello.hellospring.controller; import hello.hellospring.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; i..
테스트코드를 작성하는 궁극적인 목표는 잘 작동하는 깔끔한 코드를 얻기 위함이다. 왜 테스트코드를 통해 깔끔한 코드를 얻을 수 있을까? 그 이유는 테스트를 하기 위해서 애플리케이션 코드를 쉽게 작성하게 되기 때문이다. 아래와 같은 service요소의 MemberService클래스가 있다고 가정하자 package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import java.util.List; import java.util.Opt..
가장 일반적인 웹 애플리케이션 계층 구조를 살펴보자 각 계층별 역할은 아래와 같다 Controller : MVC방식에서의 Controller 역할과 동일하다 Service : 핵심 로직을 구현한다 Repository : DB에 접근하거나, Domain 객체를 DB에 저장 / 관리한다 Domain : 애플리케이션의 도메인 객체이다. 도메인 객체에는 회원, 주문, 쿠폰번호등이 해당되며, DB에 저장 / 관리된다.
API란? 기본적인 API의 의미는 Application Programming Interface의 약자이다. 이는 일종의 소프트웨어 인터페이스이며, Third Party 소프트웨어를 제작하거나, 관련 소프트웨어 제작 인터페이스를 제공하는것을 의미한다. 다만, 웹에서의 API의 의미는 개발자가 브라우저 상에 쉽게 개발할 수 있도록 도와주는 객체 모음이다.웹 API는 객체 기반으로 동작하며, 엔트리 포인트가 존재한다. 기본적인 Spring API 방식 String 타입 Response 우선 아래와 같은 코드를 보자 @Controller public class HelloController { // Basic API Returns String @GetMapping("hello-spring") @ResponseB..
MVC? MVC패턴은 디자인 패턴중 하나이다. Model, View, Controller의 약자이며, 각각 서로 맡은 책임을 기반으로 프로젝트가 구상된다. Model : 주로 DB 접근을 한다 View : Template관련 책임을 맡는다. Django에서는 Template이 View의 역할을 한다. Controller : Request에 대해, Template엔진연결, 필요한 Model 접근등,전반적인 통제 역할을 한다. Django에서는 View가 Controller 역할을한다 스프링에서 기본적인 Controller, View 방식 사용해보기 컨트롤러는 아래와 같이 작성해 주었다. @RequestParam을 사용하면 URL을 통해 매개변수를 받을 수 있다. @RequestParam의 매개변수중 val..
정적 컨텐츠란 서버에서 따로 프로그래밍적 처리 없이 파일을 바로 클라이언트에 전달하는 방식을 의미한다. 예를들면 Spring Welcome Page를 예로 들 수 있다. 스프링 Static Content 관련 Document를 살펴보자 https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.static-content Spring Boot Reference Documentation This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-conf..
1. Welcome Page? 기본적으로 스프링 프로젝트를 초기화하고 디폴트 클래스를 실행하면 아래와 같이 에러페이지가 나온다 이는 첫 페이지에 매핑된 페이지가 없어서 출력하는 에러페이지이다. 스프링에서는 Welcome Page 기능이 있다. Welcome page란 처음 들어갔을때 표시되는 기본 페이지를 의미한다. https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.welcome-page Spring Boot Reference Documentation This section goes into more detail about how you should use Spring Boot. It co..
1. 개발환경 개발환경은 아래와 같이 사용한다 PC : Mac(m1) Java Version : 11 https://www.azul.com/downloads/?version=java-11-lts&os=macos&architecture=arm-64-bit&package=jdk Downloads Download Azul Platform Prime Azul Platform Prime extends Core, adding unique Azul innovations to improve the runtime characteristics of Java workloads. Azul Platform Prime delivers added performance, scale, consistency, and efficiency..
Hoplin
'Back-End/Java Spring Boot' 카테고리의 글 목록