我应该先学什么,Spring 还是 Hibernate?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/722121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What should I learn first, Spring or Hibernate?
提问by ajushi
I've just started learning Struts and I'm trying to be marketable for a good job as a Java programmer. My next decision would be choosing which to learn next, Spring or Hibernate?
我刚刚开始学习 Struts,我正在努力成为一名 Java 程序员的好工作。我的下一个决定是选择接下来学习哪个,Spring 还是 Hibernate?
Also do you guys have any suggestions or tips for me to be good? Thanks in advance!
另外你们有什么建议或提示让我变得更好吗?提前致谢!
回答by Jon Skeet
I'd suggest learning Spring. Learn just the basics, and then when you docome to learn Hibernate you'll be able to take advantage of all the Spring helpers which make Hibernate easier to use.
我建议学习Spring。学习只是基础知识,然后当你这样做来学习Hibernate,您就可以把所有的春天佣工这使得Hibernate的更易于使用的优点。
There's also the point that Spring is useful in many layers instead of just at the data access part :)
还有一点是 Spring 在许多层中都很有用,而不仅仅是在数据访问部分:)
回答by topchef
Spring and Hibernate are 2 very complimentary technologies and depending on the needs you may use both, either or none. But the fundamentals both of these frameworks rely upon are 100% marketable and more importantly are required for any seasoned professional.
Spring 和 Hibernate 是 2 种非常互补的技术,根据需要,您可以两者都使用,也可以不使用。但是这两个框架所依赖的基础是 100% 适销对路的,更重要的是,任何经验丰富的专业人士都需要这些基础。
There is little value in learning Hibernate without first obtaining fundamental knowledge on relational data modeling, relational database design, and transaction processing. So these should be your pre-requisites for Hibernate.
如果不先获得关系数据建模、关系数据库设计和事务处理的基础知识,学习 Hibernate 的价值就很小。所以这些应该是你使用 Hibernate 的先决条件。
There is little value in learning Spring without first obtaining fundamental knowledge on design patterns, dependency injection, and application design (as general as it sounds you need to understand things like application tiers, class and package dependencies, MVC (sounds like you are familiar with this one via Struts), security and web standards, and of course fundamentals of OOD).
如果没有首先获得有关设计模式、依赖注入和应用程序设计的基本知识,学习 Spring 几乎没有什么价值(尽管听起来很笼统,但您需要了解应用程序层、类和包依赖项、MVC(听起来您很熟悉)这个通过 Struts)、安全和 Web 标准,当然还有 OOD 的基础)。
By learning both you will become if not marketable but at least very solid professional who is confident and comfortable in working on majority of Java (and not just Java) applications.
通过学习两者,您将成为即使没有市场但至少非常可靠的专业人士,他们对大多数 Java(而不仅仅是 Java)应用程序的工作充满信心和舒适感。
回答by Uri
I think Hibernate is fairly easy and straighforward to get basic usage skills in, and perhaps more importantly, the EJB3 is becoming a standard.
我认为 Hibernate 相当容易和直接获得基本的使用技能,也许更重要的是,EJB3 正在成为一个标准。
Spring is an external technology, not part of J2EE officially, so it might make sense to do it second, it also has a lot more facets and you really want a good book for it.
Spring 是一种外部技术,不是正式的 J2EE 的一部分,所以它可能是有意义的,它还有更多的方面,你真的想要一本好书。
回答by duffymo
Spring is far bigger and more generally applicable than Hibernate is. You decision is a trade-off between the length of the learning curve and the utility you'll have when you're done.
Spring 比 Hibernate 大得多,也更普遍适用。您的决定是在学习曲线的长度和完成后您将拥有的效用之间的权衡。
I'd recommend Spring, because it can either co-exist with both Struts and Hibernate OR supply alternatives for either one (Spring web MVC and Spring JDBC).
我推荐 Spring,因为它既可以与 Struts 和 Hibernate 共存,也可以为其中之一(Spring web MVC 和 Spring JDBC)提供替代方案。
Spring will have a beneficial effect on your Java EE designs. Start with that.
Spring 将对您的 Java EE 设计产生有益的影响。从那开始。
回答by Paras
If the objective it to learn MVC framework and how to use ORM with that framework, then logical way to learn is Spring and then Hibernate. In my opinion, in that way you will be able to grasp the concepts easily
如果目标是学习 MVC 框架以及如何在该框架中使用 ORM,那么学习的逻辑方法是 Spring 和 Hibernate。在我看来,这样你就能轻松掌握概念
回答by Gary Kephart
I learned Hibernate by itself first, and then I learned how Spring makes it much easier.
我首先自学了 Hibernate,然后我了解了 Spring 如何使它变得更容易。
回答by fforw
I wouldn't go for Struts these days.. If you're already considering Spring you should also take a look at Spring MVC, especially the newer Annotation-based Controllers are really nice to work with.
这些天我不会去使用 Struts .. 如果您已经在考虑使用 Spring,那么您还应该看看 Spring MVC,尤其是较新的基于注解的控制器非常适合使用。
I would suggest learning Spring before Hibernate because it is much easier to learn if you stick to the core and maybe WebMVC, which is what I would recommend. Spring grew quite a bit in the last releases but the core is still simple and easy to understand.
我建议在 Hibernate 之前学习 Spring,因为如果你坚持核心和 WebMVC,学习会容易得多,这就是我推荐的。Spring 在上一个版本中增长了很多,但核心仍然简单易懂。
Hibernate is a lot more complicated. I would recommending understanding the general purpose of an ORM like Hibernate, learn the hibernate annotations way of configuring hibernate and then go straight for the Spring/Hibernate Integration because it makes many things much easier. If your domain has more than just a few base types, you could also take a look at the GenericDAO pattern
Hibernate 要复杂得多。我建议您了解像 Hibernate 这样的 ORM 的一般用途,学习配置 hibernate 的 hibernate 注释方式,然后直接进行 Spring/Hibernate 集成,因为它使许多事情变得容易得多。如果您的域不仅仅是几个基本类型,您还可以查看GenericDAO 模式
回答by cliff.meyers
I would go with Spring first. Spring has so many different pieces that are useful: dependency injection, aspect-oriented programming, JDBC helper classes, an entire MVC framework and loads more. You can use as little or as much of Spring as you want on your first application and the reference documentation is truly excellent. You can easily learn Spring without buying even a single book on it.
我会先和 Spring 一起去。Spring 有很多有用的不同部分:依赖注入、面向方面的编程、JDBC 帮助类、整个 MVC 框架和加载更多。您可以在您的第一个应用程序中使用尽可能少或尽可能多的 Spring,并且参考文档确实非常出色。您可以轻松地学习 Spring,而无需购买一本关于它的书。
回答by Paco
I would consider to learn them both at the same time. Spring and NHibernate are both large frameworks with a high learning curve. It will take you some studying and experimenting time to become familiar with and good at it. When you are busy with both the frameworks, you will automatically focus on the most useful parts of them first. Learning the important parts first will make the learning curve steeper.
我会考虑同时学习它们。Spring 和 NHibernate 都是具有很高学习曲线的大型框架。你需要一些学习和实验时间来熟悉并擅长它。当您忙于这两个框架时,您将自动首先关注它们中最有用的部分。首先学习重要的部分会使学习曲线更陡峭。
回答by RN.
I think you should share your profile in a brief to get a better answer
我认为您应该简要分享您的个人资料以获得更好的答案
However... Both hibernate and spring are hot and you will find them in all job requirements posted for enterprise applications- so you are on the right track as far as your selection choices is concerned.
但是... hibernate 和 spring 都很热门,您会在为企业应用程序发布的所有工作要求中找到它们 - 因此就您的选择而言,您走在正确的轨道上。
IMHO- hibernate is trickier than Spring The reason for that is- Spring by virtue of its architecture is least invasive to the code There is little API to master. So to code in Spring- you don't have to really code anything beyond Java But to code hibernate- you need to know the Hibernate APIs and the gotchas of hibernate programming. The basics of hibernate are easy to master- but to learn the tricks and trivias- it takes time
恕我直言- hibernate 比 Spring 更棘手 原因是- Spring 凭借其架构对代码的侵入性最小 几乎没有 API 需要掌握。因此,要在 Spring 中编写代码——您不必真正编写 Java 以外的任何代码,但要编写 hibernate 代码——您需要了解 Hibernate API 和 Hibernate 编程的陷阱。休眠的基础知识很容易掌握 - 但要学习技巧和琐事 - 需要时间
If I was the hiring manager and were using hibnernate and Spring I would rather take someone who was stronger on Hibernate rather than someone who was stronger on Spring As far as spring is concerned- you as a contributing programmer- will have little to worry about Most likely the application will already have a framework in place- and you will have to plug in your contributions in.
如果我是招聘经理并且正在使用 hibnernate 和 Spring,我宁愿选择一个在 Hibernate 上更强大的人,而不是一个在 Spring 上更强大的人就 spring 而言——你作为一个贡献的程序员——几乎不用担心大多数应用程序可能已经有一个框架 - 您必须插入您的贡献。
But to code in hibernate- like I said before- its better if you have soem experience on this
但是在休眠中编码 - 就像我之前说的 - 如果你有这方面的经验会更好
PS: I know everyone has a different viewpoint on this- so you maybe getting more confused .I think- once you share a bit of your profile- it will help people give you a better advice. Good luck !!!
PS:我知道每个人对此都有不同的看法——所以你可能会更困惑。我想——一旦你分享了一些你的个人资料——它会帮助人们给你更好的建议。祝你好运 !!!

