Spring basics-01, spring-01
IOC: inversion,
DI: dependency injection refers to injecting the called instance into the caller.
AOP is a reflection of the proxy mode. Spring uses JDK's dynamic proxy by default, mainly the proxy interface. If the business object does not implement the interface, CGLIB proxy is used by default.
For example:
Xml configuration
<! -- AOP configuration --> <aop: config> <aop: aspect id = "logAspect" ref = "logService"> <aop: pointcut id = "targetMethod" expression = "execution (* org. best. spring. aop. *. *(..)) "/> <aop: after pointcut-ref =" targetMethod "method =" doLog "/> </aop: aspect> </aop: config> <! -- Log Service --> <bean id = "logService" class = "org. best. spring. xx"> </bean> <! -- Common Business bean --> <bean id = "targetService" class = "org. best. spring. xxxxx"> </bean>
Practical code to get bean:
// Create Spring context ApplicationContext ctx = new ClassPathXmlApplicationContext (new String [] {"aop/TestAOP. xml "}); TargetService ts = (TargetService) ctx. getBean ("targetService ");
// Process the business logic ....
The problem is that my directory structure is:
How does ClassPathXmlApplicationContext read TestAOP. xml ?? To be resolved, mark