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;
}
}Last updated
Was this helpful?