杂记: 默认使用return @ResonseBody
1,aop
暂时只介绍注解模式的aop,日志案例
第一种
@Aspect
public class Log {
//在方法里指定调用位置,然后execution指定具体执行哪个方法时候执行
@Before("execution(* com.xkcoding.properties.dao.UserServiceImp.getUser(..))")
public void before(){
System.out.println("-----方法执行前------");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean id="userDAOImp" name="userDAOImp" class="com.xkcoding.properties.dao.UserDAOImp"></bean>
<!-- constructor-arg 构造方法来配置资源-->
<bean id="UserServiceImp" name="userServiceImp" class="com.xkcoding.properties.dao.UserServiceImp" scope="singleton" autowire="byName">
<!-- <property name="userDAO" ref="userDAOImp"></property>-->
</bean>
<bean id="Log" class="com.xkcoding.properties.proxy.Log"></bean>
//自动注入
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>
第二种
在beans里面通过xml宏观管理组件的方式
<aop:config>
<aop:aspect ref="Log">
//第一个*是返回值
<aop:pointcut id="pointcut" expression="execution(* com.xkcoding.properties.dao.UserServiceImp.getUser(..))"/>
<aop:before method="before" pointcut-ref="pointcut"/>
</aop:aspect>
</aop:config>
2,mybatis的xml注入,一步步利用容器创建想要的实例<br />![image.png](https://cdn.nlark.com/yuque/0/2020/png/750718/1599722930735-16628fbd-163d-4557-807e-9355146c3911.png#align=left&display=inline&height=383&margin=%5Bobject%20Object%5D&name=image.png&originHeight=383&originWidth=849&size=403634&status=done&style=none&width=849)<br />2, bean的缓存<br />[https://zhuanlan.zhihu.com/p/186212601](https://zhuanlan.zhihu.com/p/186212601)<br />3,bean的注解版使用 [https://www.cnblogs.com/feiyu127/p/7700090.html](https://www.cnblogs.com/feiyu127/p/7700090.html)
@Configuration
public class AppConfig {
@Bean
public TransferService transferService() {
return new TransferServiceImpl();
}
}
等同于
<beans>
<bean id="transferService" class="com.acme.TransferServiceImpl"/>
</beans>
生命周期PostConstruct详解 https://www.jianshu.com/p/98cf7d8b9ec3
4,关于controller跳转问题 https://blog.csdn.net/qq_19648309/article/details/65627375