me hungry!
  • migrate to herdin.github.io
  • DEV TOOLS
    • IDE
      • VSCode
        • spring-boot maven config
  • Spring
    • default
      • IoC
      • resource
      • validation
      • data bind
      • SpringEL
      • DispatcherServlet
    • debug
      • mariadb connection time out - connection pool
  • Database
    • MariaDB
      • command history
  • LINUX
    • CentOS
      • install java
      • install, setting maven
      • install, setting vault
      • upgrade docker to docker-ce
  • WINDOW
    • Road to window docker
  • Arduino
    • default
    • SENSORS
      • dust sensor
        • GP2Y1010AU0F
      • humidity&temperature
        • DHT11
      • lcd
        • SKU DFR0009 - shield
    • debug
Powered by GitBook
On this page

Was this helpful?

  1. Spring

default

<servlet-name>myservlet</servlet-name>
<!-- 서블릿 명이 위와 같을 때 기본 설정파일은 /WEB-INF/myservlet-servlet.xml 이 된다. -->
//MyComponent class 의 default bean id : myComponent
@Component
public class MyComponent {
    // ...
}

/* bean id 를 지정할 수 있다.
 * carmelCase 가 convention 이다. */
@Component("realComponent")
public class MyComponent {
    // ...
}

/* type 을 서치하는 @Autowired 에서 같은 타입이 여러 개 일때,
 * 이름을 지정하여 주입받을 수 있다. */
@Autowired
@Qualifier("oracleDatabase")
private Database database
/* APO 예제 */
@Target(ElementType.METHOD)
public @interface LogCheck {}

@Component
@Aspect
public class LogChecker {
    private Logger logger = LoggerFactory.getLogger(LogChecker.class);
    @Around("@annotaion(LogCheck)")
    public Object checkLog(ProceedingJoinPoint joinPoint) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        Object proceed = joinPoint.proceed();
        stopWatch.stop();
        this.logger.info(stopWatch.prettyPrint());
        return proceed;
    }
}
AutowiredAnnotationBeanPostProcessor 가 동작하여 Initialize 전에 @Autowired 를 처리
@Autowired 로 받을 Bean 의 동일 타입이 여러개일 때,
1. @Primary 를 Bean 에 붙여 우선순위를 준다
2. List<Bean> 형태로 모두 주입받는다
3. @Qualifier("") 로 Bean 을 특정한다.
AOP (Aspect Oriented Programming)
  스프링 AOP 는 프록시로 구현
  AspectJ 는 바이트코드 조작으로 구현

PSA (Portable Service Abstraction): 잘 만든 인터페이스

스프링 트랜잭션
  캐시: @EnableCaching - CacheManager 가 있어야함
  스프링_웹:
    MVC: @Controller, @RequestMapping

Spring IoC Container
  implements: BeanFactory
Bean
  Spring IoC Container 가 관리하는 객체
  Scope
    - Singleton
    - Prototype: 매번 새로운 객체를 을 만든다
  Life Cyle interface
    - @PostConstruct
    - implements InitializingBean, @Override afterPropertiesSet()
    - @Bean(initMethod = "initMethodName")
    - @Bean(destroyMethod = "destroyMethodName")
    - @PreDestroy
    - implements DisposableBean, @Override destroy()

ApplicationContext
  API_DOC: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/ApplicationContext.html
  inplements: BeanFactory, ApplicationEventPublisher, EnvironmentCapable, ListableBeanFactory, MessageSource, ResourceLoader, ...
  ClassPathXmlApplicationContext:
    API_DOC: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/support/ClassPathXmlApplicationContext.html
    config: xml file
  annotaion bean scanning: after 2.5
  AnnotationConfigApplicationContext:
    API_DOC: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/AnnotationConfigApplicationContext.html
    config: @Configuration, @ComponentScan(basePackageClasses = ..class)

Previousspring-boot maven configNextIoC

Last updated 5 years ago

Was this helpful?