1、如何注入常量
@Value("${upload.filePath}")
2、如何配置Service、controler、DAO
@Controller
@Service("orgService")重命名为orgService否则按照orgServiceImpl命名
@Repository
3、如何配置延迟加载
@Lazy(false)
4、如何配置bean的作用域
@Scope("singleton")
5、如何配置IBatis2.x版本的SqlMapClientTemplate
原有的SqlMapClientDaoSupport的setSqlMapClient是final方法,所以不能重写并标记为@Autowired
6、如何在域的位置注入bean
@Resource(name="beanId")
7、如何配置事务
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
表明为cglib的代理方式:proxy-target-class="true"
8、全局性配置
<context:component-scan base-package="com.resoft.prophet" />
9、如何将整个类的方法配置为事务包裹的方法
@Transactional
public class A{
}
定义在类上的 @Transactional
注解指定了类中所有方法执行时的默认事务语义。
10、设置@Transactional(readOnly = true)有效吗,大多数是有效的,但是据说的确需要数据库的支持,经测试在mysql中没有问题,如果插入数据库,会报错
@Transactional(readOnly = true)
public void insertDept(Department department) throws EntityExistedException {
if (departmentDAO.isDeptExisted(department)) {
throw new EntityExistedException("您输入的部门全称已存在,请更换。");
}
departmentDAO.insertDept(department);
}
11、默认是bytype的注入,如何byName注入?
12、@Autowired(required=true)在初始化时就校验
13、默认的事务annotation配置是?
事务传播设置是 PROPAGATION_REQUIRED
事务隔离级别是 ISOLATION_DEFAULT
事务是 读/写
事务超时默认是依赖于事务系统的,或者事务超时没有被支持。
任何 RuntimeException
将触发事务回滚,但是任何 checked Exception
将不触发事务回滚
14、如何标记多个事务属性???
@Transactional(readOnly = true)
@Transactional(readOnly = true, rollbackFor = { BusinessException.class })
15、配置单元测试加载配置文件的注解
@ContextConfiguration(locations = { "/cache/applicationContext-ehcache.xml" })
分享到:
相关推荐
Spring的Annotation配置相关讲义
Spring Annotation
Spring_Annotation_AOP
spring的Annotation注解.
Spring annotation 样例
Spring+mybatis annotation形式 进行增删查改,使用maven容器,配置完整,自己运行多次无问题
spring 使用annotation替代xml配置实例
Spring IOC Annotation 注入 学习实例
spring的annotation-driven配置事务管理器详解 (多数据源配置
spring annotation 注解 maven 配套的源码
spring使用annotation整合dwr笔记 spring使用annotation整合dwr笔记 spring使用annotation整合dwr笔记
详解 Spring 3.0 基于 Annotation 的依赖注入实现。。详解 Spring 3.0 基于 Annotation 的依赖注入实现。。
spring的annotation的autowired配置方法。
马士兵视频里的struts2 hibernate3 spring2.5 annotation 整合 绝对好用 里面还有jar包 部署就可以用
配置整合DWR3.0和Spring2.5使用annotation注解
SpringMVC Spring MyBatis 框架整合 Annotation Maven Project
详解Spring基于Annotation的依赖注入实现
Spring_Annotation_IOC