전체 글 89

java.lang.NullPointerException

java.lang.NullPointerException: Cannot invoke "hello.core.discount.DiscountPolicy.discount(hello.core.member.Member, int)" because "this.discountPolicy" is null private final DiscountPolicy discountPolicy = new FixDiscountPolicy(); 원래 이 코드를 DIP원칙에 맞는 코드를 작성하기위해 discountPolicy의 구현 클래스를 아래처럼 삭제하여 아무것도 할당되지 않아 발생 private DiscountPolicy discountPolicy; 쉽게 말해 null값에 .을 찍어서 발생 ..

에러 모음 2024.04.10

SOLID 란?

SOLID는 좋은 객체 지향 설계의 5가지 원칙을 말한다 • SRP: 단일 책임 원칙(single responsibility principle) • OCP: 개방-폐쇄 원칙 (Open/closed principle) • LSP: 리스코프 치환 원칙 (Liskov substitution principle) • ISP: 인터페이스 분리 원칙 (Interface segregation principle) • DIP: 의존관계 역전 원칙 (Dependency inversion principle) 이렇게 5가지이며 이 5가지를 하나씩 알아보자 1. SRP 단일 책임 원칙 한 클래스는 하나의 책임만을 가져야 한다 쉽게말해 변경을 했을때 파급이 적게하는게 단일 책임 원칙을 다른것 극단적인 예로 UI하나의 변경을 하는데..

공부/SPRING 2024.04.10

[GitHub]GitHub에 올리기

인텔리제이에서 터미널 열고 1. git init 2. git branch -M main 3. git add . (전체 올릴경우 . 아니면 하니씩 입력하면됨) 4. git commit -m '적을 메시지' 5. git push -u https://github.com/깃 주소.git main 깃 주소 1. Repositories에서 New버튼 클릭 2. Repository name, Description 입력 3. 주소창 복사 Repositories에 들어가 New버튼 클릭 Repository name에 저장소로 생성할 이름 입력 Description에 이 저장소에관한 간단 설명 작성 그러면 위 사진처럼 .git으로 끝나는 저장소 주소가 나옴 이 주소를 복사해 push하면 됨

Tip 2024.04.08

스프링 웹 개발 기초(정적 컨텐츠, MVC와 템플릿 엔진,API)

스프링 웹 개발 기초 1. 정적 컨텐츠 : 파일을 있는 그대로 웹브라우저에게 보내는 방식 동작 >> 웹브라우저에서 localhost8080/hello-static.html 검색하면 내장 톰캣서버가 이 요청을 받고 먼저 컨트롤러가 있는지 찾아보고 없으면 resources: static/hello-static.html을 찾아 서 반환 2. MVC와 템플릿 엔진 : 서버에서 바꿔서 html을 전달하는 방식 MVC : Model,View,Controller (관심사의 분리) 동작 >> localhost:8080/hello-mvc 넘기면 내장톰캣이 spring에게 전달 helloController에 Mapping이 된걸 확인하고 그 메서드를 호출, return해줄때 이름은 hello-template로 model에..

공부/SPRING 2024.04.08

MissingServletRequestParameterException

.MissingServletRequestParameterException: Required request parameter 'name' for method parameter type String is not present @GetMapping("hello-mvc") public String helloMvc(@RequestParam("name") String name,Model model ) { //외부에서 파라미터 받고 model에 담음 model.addAttribute("name",name); //파라미터로 넘어온 name을 model에 담아 넘겨줌 return "hello-template"; } @RequestParam("name")에서 name값을 안줘서 발생 < 해..

에러 모음 2024.04.08