개발/Spring
-
(스프링 기본) 5 - 객체 지향 설계와 스프링개발/Spring 2024. 10. 2. 23:00
■ 스프링에서 왜 객체 지향 이야기가 나올까?- 스프링은 아래 기술로 다형성 + OCP, DIP 를 가능하게 지원 > DI(Dependency Injection) : 의존관계, 의존성 주입 > DI 컨테이너 제공 : 자바 객체를 컨테이너에 넣고 그 안에서 의존관계를 주입시킴- 클라이언트 코드의 변경 없이 기능 확장- 쉽게 부품 교체하든 개발 가능 ■ 스프링 없었을 때- 좋은 객체 개발을 하려고 OCP, DIP 원칙 지키려고 하다 보니 할 일이 많아짐 > 프레임워크로 만들어버림- 순수 자바 개발을 하면, 결국 스프링 프레임 워크를 만들게 된다. (정확히는 DI 컨테이너) ■ 정리- 모든 설계에 역할과 구현 분리하자ex) 자동차, 공연- 애플리케이션 설계도 공연을 설계 하듯이 배역만 만들어두고, 배우..
-
(스프링 기본) 4 - 좋은 객체 지향 설계 5가지(SOLID)개발/Spring 2024. 10. 2. 22:50
■ SOLID란?: 클린 코드로 유명한 로버트 마틴이 말한 좋은 객체 지향 설계의 5가지 원칙 1. SRP(Single responsibility principle) 단일 책임 원칙- 한 클래스는 하나의 책임만 가져야 한다.- 중요한 기준은 변경으로, 변경이 있을 때 파급 효과가 적으면 단일 책임 원칙을 잘 따른 것ex) UI 변경, 객체의 생성과 사용을 분리 2. OCP(Open/closed principle) 개방-폐쇄 원칙- 소프트웨어 요소는 확장에는 열려 있으나 변경에는 닫혀 있어야 함- 다형성을 활용- 역할과 구현의 분리ex1) 자동차 종류를 k3, 아반떼로 늘려도 자동차라는 역할은 바뀌지 않아 운전자는 차를 움직일 수 있음ex2) 연극의 로미오라는 역할은 다른 사람으로 바뀌어도 계속 사용 가능..
-
(스프링 입문) 3 - 회원 관리 예제 : 백엔드 개발 (비즈니스 요구사항 정리 + 회원 도메인과 리포지토리 만들기 + 회원 리포지토리 테스트 케이스 작성 + 회원 서비스 개발 + 회원 서비스 테스트)개발/Spring 2023. 7. 30. 00:15
■ 비즈니스 요구사항 정리 컨트롤러 : 웹 mvc 컨트롤러 역할 서비스 : 회원 중복 가입 안된다. 도메인 : 회원, 주문, 쿠폰 데이터베이스 저장하고 관리되는 비즈니스 도메인 객체 리포지토리 : 데이터베이스에 접근, 도메인 객체를 db에 저장하고 관리 아직 데이터 저장소가 선정되지 않아서, 우선 인터페이스로 구현 클래스를 변경할 수 있도록 설계 데이터 저장소는 RDB, NoSQL 등등 다양한 저장소를 고민중인 상황으로 가정 개발을 진행하기 위해서 초기 개발 단계에서는 구현체로 가벼운 메모리 기반의 데이터 저장소 사용 ■ 회원 도메인과 리포지토리 만들기
-
(스프링 입문) 2 - 스프링 웹 개발 기초 (정적 컨텐츠 + MVC와 템플릿 엔진 + API)개발/Spring 2023. 7. 29. 23:07
■ 정적 컨텐츠 static 정적 컨텐츠는 파일 그대로 고객에게 웹 브라우저에 나타내는 방법이다. 다음과 같이 html 파일을 만들어주면 화면 그대로 보여줄 수 있다. * 에러해결 html 을 생성했음에도 화면에 안나오는 오류 발견 이는 포트 중복으로 cmd 에서 프로세스 종료 후 다시 프로젝트 실행하면 해결된다. 현재 8080 포트로 실행중인 프로세스 ID 찾기 netstat -ano | findstr 8080 프로세스 ID로 프로세스 강제 종료하기 taskkill /f /pid 프로세스ID 웹브라우저가 hi-static.html 톰켓 서버가 명령 받은것 스프링에게 넘긴다. 스프링 부트 컨트롤러에서 있는지 찾는다 (우선 순위 먼저 가짐) 그러나 맵핑된 컨트롤러가 없어서 리소스에서 이것을 찾고 이를 다시..
-
(스프링 입문) 1 - 프로젝트 환경설정(프로젝트 생성 + 라이브러리 살펴보기 + View 환경설정 + 빌드하고 실행하기)개발/Spring 2023. 7. 29. 17:55
■ 프로젝트 생성하기 1. 프로젝트 Maven vs Gradle : 필요한 라이브러리를 가져오고 빌드하는 라이브 사이트까지 관리하는 툴이다. 과거에는 메이븐 많이 사용했지만 요즘은 Gradle 많이 사용한다. 2. 언어 -> 자바 선택 3. 스프링 부트 snapshot : 만들고 있는 중 m1 : 정식 출시된 버전x 4. Project Metadata - Group : 보통 기업 도메인 적는다. - Artifact : build 후 결과믈 (프로젝트 명 같은 것) 5. Dependencies (★) - 어떤 라이브러리 땡겨서 쓸건가 - spring web 선택 - 템플릿 엔진 Thymeleaf 선택 (회사마다 다르다) 다 완료되었다면 하단에 Generate 로 다운받기 https://start.sprin..