Spring常用注解

来源:互联网 发布:win32编程视频教程 编辑:程序博客网 时间:2024/06/05 15:14

FastJson时间格式化:
@JSONField(format = “yyyy-MM-dd hh:mm:ss”)

单元测试加载Spring配置:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = “classpath:spring/spring-context.xml”)
@WebAppConfiguration

读取.properties文件:
@Value(“${ShortURLAPIAddress}”)

用于标注业务层组件:
@Service

用于标注控制层组件(如struts中的action):
@Controller

用于标注数据访问组件,即DAO组件:
@Repository

泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注:
@Component

注释使得接口可以被容器注入:
@Autowired