Spring框架
任何人都可以用简单的方式(或者如果网络上存在简单的教程)解释 Spring IOC 应用程序如何运行,并只执行 CRUD 工作?
我这样做了: 1. 使用 hibernate 创建类特定文件。 2. 将这些类扩展为“bean”,除了扩展 hibernate 对象之外,还可以执行一些业务人员操作。 3.创建了一些中间类来完成更广泛范围的操作工作 4. 创建一个applicationContext 文件。 5.所有的“bean”都是通过“中间人”一些插件机制消耗的。例如CarType类,在Spring的applicationContext中我分配了CarType类的几个类。因此,对此进行迭代,假设获取 CarType 的所有这些 bean。
不幸的是,最后我这样做了: CarBean car = new CarBean() 或 CarBean car = CarBean.load(long id ) ! 突然Spring又没用了。 春天适合在哪里?它是如何使用的?以巧妙的方式。
在网络上,我总是看到有关有趣的 bean 机制的教程或令人沮丧的 spring 文档。但没有肉!
我从之前维护的应用程序中得到的唯一线索是,它应该在内存中运行 Bean,然后 Bean 从数据库中检索数据。
如果你觉得这一切很糟糕,想象一下我的公司发生了很多变化,而这个负担落在了我身上。最初写那个 Spring 的人从来没有评论过一行。并使用了让我受苦的命名方案。我必须阅读 Spring/Hibernate/PHP/.net/asp.net 等等。现在我写了一个新的应用程序并尝试弥补一些好东西,但我担心我把它丢失在某个地方......
提前谢谢你......
Can anyone explain with a simple way ( or with a simple tutorial IF exists on web ), how a Spring IOC application could be run, and do just a CRUD job?
I did this:
1. With hibernate created class specific files.
2. Extended these classes to "beans" that beside extending hibernate objects, do some business staff.
3. Created some middler classes that do operation job with wider scope
4. Created an applicationContext file.
5. All the "beans" are consumed through a "Middleman" Some plugin mechanism. For example CarType class, where in Spring's applicationContext I assigned to be several class of CarType class. So an iteration on that, supposes to fetch all those beans of CarType.
Unfortunatelly, in the end, I ended up doing that: CarBean car = new CarBean() or CarBean car = CarBean.load(long id ) !
Suddenly Spring was useless again.
Where does Spring fits? How is it used ? In clever way.
In the web, I see all the time, tutorials about funcy bean mechanisms or the spring docs that are frustrating. But no meat!
The only clue, I had from the previous application that I maintained, was that it supposed to run beans in memory, and then beans retrieve data from db.
If you find it awful all this, imagine that my company had many changes, and the burden of this fell on me. The guy who wrote that Spring in the first place, never commented a line. And used naming schemes that made me suffer. I had to read Spring/Hibernate/PHP/.net/asp.net and many more. Now I write a new application and try to make up some good things,I fear I lost it somewhere though...
Thank you in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,当我们引入 DI 框架时,我们会感到有点不知所措,这是我们编程方式的范式转变。我们大多数人一开始都在同一条船上。但如果你理解一些基本概念,那么一切就变得有意义了。我建议您按以下顺序阅读一些内容。
控制反转 (IoC)
First it is little bit overwhelming when we get introduced to a DI framework and it is a paradigm shift in the way we program. Most of us were in the same boat in the begining. But if you understand some basic concepts then everything starts to make sense. I suggest you do some reading in the below order.
Inversion of Control (IoC)