WEB 158

김영한 (스프링 핵심원리 2) 스프링의 핵심원리이해 1 - 예제 만들기

비즈니스 요구사항과 설계 회원 회원을 가입하고 조회 할 수 있다. 회원은 일반과 VIP 두 가지 등급이 있다. 회원 데이터는 자체 DB를 구축할 수 있고, 외부 시스템과 연동할 수 있다. 주문과 할인정책 회원은 상품을 주문할 수 있다. 회원 등급에 따라 할인 정책을 적용할 수 있다. 할인 정책은 모든 VIP는 1000원을 할인해주는 고정 금액 할인을 적용해달라. 할인 정책은 변경 가능성이 높다. 회사의 기본 할인 정책을 아지 정하지 못헀고, 오픈 직전까지 고민을 미루고 싶다. 최악의 경우 할인을 적용하지 않ㅇ르 수 도 있다. 회원 도메인 설계 package hello.core.member; public class Member { private Long id; private String name; priv..

WEB/Spring 2021.02.09

김영한 (스프링 핵심원리 1) 객체지향설계와 스프링

G스프링 부트 Tomcat 같은 웹 서버를 내장해서 별도의 웹서버를 설치하지 않아도됨. 손쉬운 빌드 구성을 위한 starter 종속성 제공 , 외부 라이브러리 자동구성 == 메이저 라이브러리들은 스프링이 compatiable 한지 다 테스트하고 알맞은 version 을 가지고 온다. 매트릭, 모니터링을 기본적으로 어느정도 제공을 해준다. 내부적으로는 스프링 프레임워크를 다루는 것이다. 다형성 Polymorphism 변경과 수정이 용이하다 == 인터페이스가 있어서 실 구현체가 달라도 된다. 클라이언트는 대상의 역할만 알면 된다. 클라이언트는 구현 대상의 내부 구조를 몰라도 된다. 클라이언트는 구현 대상의 내부 구조가 번경되어도 영향을 받지 않는다. 클라이언트는 구현 대상 자체를 변경해도 영향을 받지 않는다..

WEB/Spring 2021.02.08

김영한 (스프링 부트 5)

AOP 중간 중간에 중요한 비지니스 로직이아닌 일반적인 것들을 끼워 넣을 때 유용하다. package hello.hellospring.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; @Aspect //@Component public class TimeTraceAop { @Around("execution(* hello.hellospring..*(..)) && !target(hello.hellospring.SpringConfig)..

WEB/Spring 2021.02.08

김영한 (스프링부트 입문) 4

H2 database 연결 jdbc:h2:tcp://localhost/D:\H2\test 이것이 나의 jdbc url 이다 저기에 test.mv.db 가 생성 될것이다. 이렇게 접속을 하는 이유는 소켓을 통해 접속하게 됨으로서 여러곳에서 접근을 가능하게 해주기 때문이다. drop table if exists member CASCADE; create table memeber ( id bigint generated by default as identity, name varchar(255), primary key(id) ); 자바 도메인 member 클래스와 동일하게 하나 만들어준다. package hello.hellospring.repository; import hello.hellospring.domain...

WEB/Spring 2021.02.08

김영한 (스프링부트 입문) 3

@Controller ,@Repostory, @Service 는 사실상 @Component이다. 스프링이 컴포넌트 스캔을 쫘악한다. 기본적으로는 HelloSpringApplication.java 맨위에 package hello.hellospring; 하위만 기본으로 스캔을 해준다. 그 위의 상위 패키지들은 따로 설정을 해주어야 한다. @Autowired 를 통한 DI는 해당 클래스가 스프링 빈으로 등록이 되어있어야지만 작동한다. 스캔을 하면서 생성자를 호출해서 객체를 생성하는데 싱글톤으로 생성해준다. @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Component public @interface Repository..

WEB/Spring 2021.01.31

김영한 (스프링부트 입문) 1

package hello.hellospring.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HelloController { @GetMapping("hello") public String hello(Model model) { model.addAttribute("data","hello!!"); return "hello"; } } 여기서 intellij 는 hello에 control을 누르면 그 해당하는 페이지로 바로 이동시켜준다!..

WEB/Spring 2021.01.24

Spring Ehcache example

캐시 설정을 할 수있게 해주는 package를 gradle을 통해 다운받는다 CommandLineRunner 인터페이스를 구현한 클래스는 구동시 run()메소드를 자동으로 호출하게합니다. 캐시를 쓰고있는 지 확인하기위하여 loger.info안의 this.cacheManager.getClass().getName()을 통해서 확인합니다. 굳이 sout을 안하는 이유는 실제 상용시스템에서는 보안이슈가 있기 때문입니다. ehcache 를 쓰기위한 xml 파일이다. 자기 스스로 캐시의 이름을 지정할 수 있다. 지금의 경우는 "findMemeberCache" 로 되어있다. package com.blogcode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; i..

WEB/Spring 2021.01.23