일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- spring batch 코드
- spring bean
- SuperTypeToken
- ORM
- spring boot
- spring camp
- Spring Data JPA
- JPA mapping
- 코드 리뷰
- Spring Batch
- IntelliJ
- docker
- Spring Data REST
- Spring
- Data REST
- spring jpa
- batch
- static inner class
- spring pid
- spring boot tomcat
- spring-mvc
- spring-webmvc #코드읽기
- ApplicationPidFileWriter
- tomcat
- 톰캣
- JPA
- REST API
- spring-webmvc
- JUnit
- 세미나
- Today
- 1
- Total
- 916,386
목록Spring (14)
woniper

DispatcherServlet 클래스를 읽어보며 여러 가지 Resolver가 존재한다는 것을 알았다. Resolver는 뜻 그대로 무언가를 해결한다는 의미다. ViewResolver는 View를 어떻게 만들 것인지, LocaleResolver는 어떻게 지역화(언어)를 선택할 것인지 해결한다. 어렵지 않은 코드라 생각해서 (사실은 귀찮아서) 여러 Resolver 코드 읽기는 하지 않겠다. 이번 글은 HandlerMapping이 무엇인지 알아보고 코드를 살펴보자. HandlerMapping의 역할 코드를 살펴보기 전에 HandlerMapping이 어떤 역할을 하는지 알아야겠다. HandlerMapping 문서에는 아래와 같이 설명한다. Request와 Handler 객체 간의 매핑을 정의한다. 프레임워크에..
Spring-MVC로 웹 애플리케이션을 개발하면 아래와 같은 Controller를 만든다. @Controller public class HelloController { @GetMapping("/hello") public String hello() { return "hello Spring~"; } } 어떻게 @Controller 선언 만으로 메소드가 실행되고, Controller 실행 전/후로 전처리, 후처리 가능한 Interceptor가 동작할까? 뿐만 아니라, 파일 업로드, View 반환 등 Spring-MVC에서 제공되는 여러 가지 기능들은 어떻게 실행될까?Spring-MVC 읽기 #5. AbstractDispatcherServletInitializer와 AbstractAnnotationCon..
이번 글은 AbstractContextLoaderInitializer 클래스의 하위 클래스인 AbstractDispatcherServletInitializer 클래스와 AbstractAnnotationConfigDispatcherServletInitializer 클래스를 살펴볼 것이다. AbstractDispatcherServletInitializer AbstractContextLoaderInitializer 클래스는 ContextLoader를 통해 root WebApplicationContext를 생성하고, 초기화(refresh)한다는 걸 이해했다. 마찬가지로 AbstractDispatcherServletInitializer 클래스는 DispatcherServlet을 생성하고 초기화한다. Abstrac..
이전 글에서 WebApplicationInitializer 구조에 대해 봤다. 이번 글은 WebApplicationInitializer 구현체 중 하나인 AbstractContextLoaderInitializer 클래스에 대해 이야기해볼 예정이다.코드를 보자. AbstractContextLoaderInitializer public abstract class AbstractContextLoaderInitializer implements WebApplicationInitializer { /** Logger available to subclasses. */ protected final Log logger = LogFactory.getLog(getClass()); @Override public void onSt..
주의) 저도 처음 코드를 읽으며 작성하는 글이기 때문에 어렵게 전달되거나, 틀린 부분은 언제든 피드백을 해주세요. 이번 글은 Spring-MVC의 시작에 대해 알아볼 것이다. public static void main(String... args) {} java 개발자라면 위 코드는 익숙하다. java에서 main 메소드는 애플리케이션의 최초 시작점이다. 그런데 Spring-MVC로 개발한 웹 애플리케이션을 war로 빌드 후 Web Application Server(이하 WAS)로 실행하는 경우엔 main 메소드가 최초 시작점이 아닌 것을 알 수 있다. WAS 실행이 최초 시작점이라고 볼 수도 있겠다. Spring Boot를 사용하면 main 메소드가 최초 시작점이다. 이 글은 Spring Boot를 이야..
Spring-MVC는 Spring Framework의 feature 중 하나다. 때문에 코드를 보기 위해서는 Sprig Framework github 코드를 clone 해야 한다. clone & build github repository clone 참고 : Build from Source $ git clone https://github.com/spring-projects/spring-framework.git build $ cd spring-framework $ ./gradlew build 프로젝트 크기가 커서 빌드가 오래 걸린다. test spring-webmvc module $ ./gradlew -a :spring-webmvc:test 코드를 clone 받아 빌드 후 spring-webmvc 모듈을 t..
가정 하나의 project에 의미가 다른 2개의 Event라는 @Entity가 필요하다. 당연히 package 경로는 다르다. 하나는 net.woniper.data.jpa.event1.Event (이하 event1) 하나는 net.woniper.data.jpa.event2.Event (이하 event2) package만 다르며, 클래스 명은 같다. 각각의 Event는 Repository가 존재한다. net.woniper.data.jpa.event1.EventRepository (이하 eventRepository1) net.woniper.data.jpa.event2.EventRepository (이하 eventRepository2) 예제 코드 net.woniper.data.jpa.event1.Event p..
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)할 수 있고, 하나의 큰 실행 단위가..
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..