一、spring4中提供了大量的注解来支持零配置,简要说明如下:
@Configuration
: 类似于spring配置文件,负责注册bean,对应的提供了@Bean注解。需要org.springframework.web.context.support.AnnotationConfigWebApplicationContext注册到容器中。@ComponentScan
: 注解类查找规则定义 @EnableAspectJAutoProxy
: 激活Aspect自动代理 @Import @ImportResource
: 关联其它spring配置 @EnableCaching
:启用缓存注解 @EnableTransactionManagement
: 启用注解式事务管理 @EnableWebMvcSecurity
: 启用springSecurity安全验证
二、结合jpa作为数据库持久层,一个具体的JpaSourceConfig
类如下:
|
|
三、一个具体的实现体的定义
|
|
四、一个具体的repository类,即dao层类
|
|
五、orm.xml配置
|
|