일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- ApplicationPidFileWriter
- tomcat
- spring-webmvc #코드읽기
- spring camp
- Spring Data REST
- spring pid
- spring-webmvc
- REST API
- batch
- JPA
- spring boot
- docker
- Spring Data JPA
- SuperTypeToken
- 코드 리뷰
- spring jpa
- JUnit
- 톰캣
- spring batch 코드
- ORM
- Spring
- JPA mapping
- IntelliJ
- spring-mvc
- spring bean
- Spring Batch
- 세미나
- static inner class
- Data REST
- spring boot tomcat
- Today
- Total
목록Spring (38)
woniper
Spring Batch를 사용해본 개발자라면 이 포스팅은 볼 필요 없다. Spring Batch의 기본 개념 (레퍼런스 문서에서는 domain이라고 표현한..)을 내 나름대로 정리하는 글이다. 이 글은 Spring Batch가 무엇인지, 왜 사용하는지 설명하지 않는다. 기본 개념 Job : Batch에서 실행 가능한 실행 단위. JobLauncher : Job을 실행하는 책임이 있다. JobRepository를 통해 Job, Step, Item* 등을 생성하고 조립. JobRepository : DB 또는 어딘가에 저장된 Job, Step 등을 조회(select) 또는 생성(insert), 수정(update). Step : Job은 1개 이상의 Step을 포함(1:N)할 수 있고, 하나의 큰 실행 단위가..
발표자료 Booting Spring Data RESTSpring Data REST 예제Spring Data REST #1 IntroductionSpring Data REST #2 동작 원리Spring Data REST #3 내부 동작 정말 Repository Interface로만 API가 동작할까? 당연히 Repository Interface만 있다고 해서 API가 동작하는 건 아니다. 우리가 Spring MVC를 사용해서 Controller를 만들어서 API를 만들듯이, Spring Data REST에는 이미 만들어진 Controller가 존재한다. 차이점이 있다면, 기존에 만들던 Controller와는 조금 다른 Spring Data REST만의 Controller를 만든다. @Reposi..
발표자료 Booting Spring Data REST Spring Data REST 예제 Spring Data REST #1 Introduction Spring Data REST #2 동작 원리 Spring Data REST #3 내부 동작 Introduction에서 Spring Data REST에 대한 간단한 소개와 사용방법을 알아봤다. Spring Data에서 제공하는 Repository interface 선언만으로 REST API가 만들어졌다. 어떻게 Repository 선언만으로 REST API가 제공될까? 위 그림은 발표 장표 중 하나다. CrudRepository에 선언된 메소드가 곧 REST API로 지원되는 것이다. @RepositoryRestResource public inte..
발표자료 Booting Spring Data REST Spring Data REST 예제 Spring Data REST #1 Introduction Spring Data REST #2 동작 원리 Spring Data REST #3 내부 동작 Spring Camp 2017에서 Spring Data REST를 소개하는 발표를 했는데, 45분이라는 시간으로 Spring Data REST(이하 Data REST)를 모두 전달하기에는 짧은 시간이다. 그래서 블로그를 통해 좀 더 많은 내용을 전달하려고 한다. Introduction Spring Data REST 레퍼런스 문서에서 REST API는 애플리케이션 통합에서 중요한 수단이고, Spring MVC를 통해 쉽게 만들 수 있지만, 간단한 REST A..
Spring Tips: The Spring Framework *Utils Classes 를 보고 정리하면 좋겠다고 생각했다. 전체 예제 DemoClass @Data @Slf4j @AllArgsConstructor @NoArgsConstructor public class DemoClass { private List list = new ArrayList(); @PostConstruct public void begin() { log.info("begin"); } } org.springframework.util.Assert @Test public void assertIsNull() throws Exception { demoClass.setList(null); Assert.isNull(demoClass.getLi..
Bean Scope를 좀 살펴보다가 아래와 같은 테스트를 돌려보았다. @Configuration public class BeanScopeConfig { @Bean public AccountService accountService() { AccountService accountService = new AccountService(); accountService.setAccountRepository(accountRepository()); return accountService; } @Bean @Scope(scopeName = "prototype") public AccountRepository accountRepository() { return new AccountRepository(); } } public c..
앞서 bean 등록(registry)과 getBean 메소드 호출 과정을 살펴보았다. 간단하게 다시 정리해보자면 bean 등록 : 메타데이터를 통해 BeanDefinition을 Map에 저장한다. getBean 처음 호출 GenericBeanDefinition을 RootBeanDefinition으로 재 정의 후 Map에 저장 bean instance 생성 후 Map에 저장 후 반환 2번 이상 호출 Map에 bean instance 꺼내와 반환 예제로 설명한 AnnotationConfigApplicationContext는 DefaultListableBeanFactory를 통해 대부분에 기능을 위임하고 있는 것을 확인했다. 그렇다면 BeanFactory와 ApplicationContext는 무엇일까? 이번 ..
Spring IoC Container를 까보자 #Bean 등록은 어떻게 될까? 라는 글에서 IoC Container인 BeanFactory와 ApplicationContext에서 어떻게 Bean을 등록하고 보관하는지 알아보았다. 이번 글에서는 등록된 Bean 정확히 말하면 BeanDefinition을 어떻게 instance 화 후 반환 하는지 알아보자. getBean 메소드의 정체 @Configuration public class BeanConfig { @Bean public AccountService accountService() { AccountService accountService = new AccountService(); accountService.setAccou..
Spring에서 IoC Container 역할을 하는 BeanFactory 와 ApplicationContext 동작 방법이 궁금했다. 작년 SLiPP에서 스터디를 했었는데, 다시 한번 블로그에 정리하려 한다. 스프링 구조 일단 스프링에서 BeanFactory와 ApplicationContext의 다이어그램을 보자. 사실 스프링 구조를 잘 이해하지 못하고 다이어그램만 보고는 각각의 interface와 class가 어떤 역할을 하는지 도통 알 수 없다. 핵심은 BeanFactory와 ApplicationContext다. ApplicationContext applicationContext = new AnnotationConfigApplicationContext(BeanConfig.class); Annotat..
전체 예제 : https://github.com/woniper/spring-example/tree/master/spring-boot-custom-bean-name-generator좀더 훌륭한 문서 : https://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics 스프링 4.0 부터 자바 제네릭 타입을 주입받을 수 있다. 4.0 미만 버전도 가능은 했지만 번거로운 추가 작업이 필요했다. 예를들어Notification 인터페이스를 구현한 3개의 구현체가 있다고 예를 들자. 12@Autowirdprivate List notifications;cs 4.0 이상부터는 Notification List Type으로 주입이 가능해졌다. 매우 편리하다...
Rest API Version Path 문제 Rest API를 만드는데 version 관리가 되어야한다.예를 들면http://localhost:8080/v1/foohttp://localhost:8080/v2/foo와 같은 URL이 필요하다. Spring에서는 @RequestMapping에 value값으로 URL을 설정할 수 있다. 위 URL을 @RequestMapping으로 표현해보자. 1234567891011@RestControllerpublic class SampleController { @RequestMapping(value = "/v1/foo") public ResponseEntity v1Foo() { return ResponseEntity.ok("v1 foo"); } @RequestMapping..
앞서 SpringApplication Class를 보면서 run 메소드 안에 StopWatch라는 클래스를 본적이 있다. 클래스 명만 보고 그냥 StopWatch 기능을하는 클래스구나하고 넘어갔는데, 오늘 문뜩 그 클래스가 생각이나서 한번 봤는데 역시나다. (java-doc 문서) SpringApplication 클래스에서 StopWatch에 사용되는 메소드는 start, stop 를 사용하고 객체를 StartupInfoLogger.logStarted 메소드에 파라미터로 넘긴다. start12345678public void start(String taskName) throws IllegalStateException { if (this.running) { throw new IllegalStateExcept..