什么是@Repository和@Autowired用于。 (弹簧) [英] what are @Repository and @Autowired used for. (Spring)

查看:1189
本文介绍了什么是@Repository和@Autowired用于。 (弹簧)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习java 3个月,有时
i无法理解某些东西的使用目的。

I am learning java for 3 months and sometimes i can not understand the usage purpose of something.

一个主题是依赖注入和春天豆我认为out the finally =)

one topic was dependency injection and spring beans i figured out the finally =)

现在我混淆了两个注释@Autowired和@Repository。
首先Autowiring是什么意思?然后
我为什么要使用它们,使用它们和不使用它们之间的区别是什么?

now i confused with the two annotations @Autowired and @Repository. First What does Autowiring mean? then Why should i use them and what is the difference between using them and not using?

今天我也尝试在spring mvc项目中使用hibernate我不得不搜索大约15(类未找到错误的原因)jar文件,因为该项目中使用的其他jar文件的依赖项。
这是不是必须这样?这使初学者学习java非常困难

Also today i tried to use hibernate in a spring mvc project and i had to search for about 15(cause of class not found errors) jar files beacuse of the dependencies of other jar files used in the project. is this had to be this way? this makes learning java very hard for the beginners

谢谢......

推荐答案

@Repository是一个注释,它将特定类标记为数据访问对象,从而阐明了它的作用。同一类别的其他标记是@Service和@Controller

@Repository is an annotation that marks the specific class as a Data Access Object, thus clarifying it's role. Other markers of the same category are @Service and @Controller

@Autowired是一个具有完全不同含义的注释:它基本上告诉DI容器注入依赖项。更多信息,请访问 http://apollo89.com/java/spring-framework-2.5.3/api/org/springframework/beans/factory/annotation/Autowired.html

编辑
更多信息,请访问 tutorialpoint

docs.spring.io

@Autowired is an annotation with a completely different meaning: it basically tells the DI container to inject a dependency. More info at http://apollo89.com/java/spring-framework-2.5.3/api/org/springframework/beans/factory/annotation/Autowired.html
Edit More info at tutorialpoint
or docs.spring.io

这篇关于什么是@Repository和@Autowired用于。 (弹簧)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆