我听说了很多关于Spring的事情,人们在网上说Spring是一个很好的web开发框架。简而言之,Spring框架到底是用来干什么的?为什么我要用它而不是纯Java。
当前回答
Spring一开始是依赖注入,然后为几乎所有的东西添加了包装之王(JPA实现的包装等)。
说来话长……Spring的大多数部分更倾向于XML解决方案(XML脚本引擎…brrrr),所以对于DI,我使用Guice
很好的库,但是随着依赖性的增长,例如Spring JDBC(可能是一个具有实名参数的Java JDBC解决方案)将从maven 4-5继承。
使用Spring MVC(“big Spring”的一部分)进行web开发…它是“基于请求的”框架,有“请求vs组件”的圣战…由你决定
其他回答
春天有三样东西。
Spring handles Dependency Injection and I recommend you read Martin Fowler's excellent introduction on dependency injection. The second thing Spring does is wrap excellent Java libraries in a very elegant way to use in your applications. For a good example see how Spring wraps Task Executors and Quartz Scheduler. Thirdly Spring provides a bunch of implementations of web stuff like REST, an MVC web framework and more. They figure since you are using Spring for the first two, maybe you can just use it for everything your web app needs.
The problem is that Spring DI is really well thought out, the wrappers around other things are really well thought out in that the other things thought everything out and Spring just nicely wraps it. The Spring implementations of MVC and REST and all the other stuff is not as well done (YMMV, IMHO) but there are exceptions (Spring Security is da bomb). So I tend to use Spring for DI, and its cool wrappers but prefer other stuff for Web (I like Tapestry a lot), REST (Jersey is really robust), etc.
与J2EE相比,Spring是一个轻量级且灵活的框架。 弹簧容器充当了控制的反转。 Spring使用AOP,即代理和单例、工厂和模板方法设计模式。 分层架构:分离关注点和可重用层,易于维护。
简而言之,我认为Spring是应用程序中的“粘合剂”。它用于集成不同的框架和您自己的代码。
Spring一开始是依赖注入,然后为几乎所有的东西添加了包装之王(JPA实现的包装等)。
说来话长……Spring的大多数部分更倾向于XML解决方案(XML脚本引擎…brrrr),所以对于DI,我使用Guice
很好的库,但是随着依赖性的增长,例如Spring JDBC(可能是一个具有实名参数的Java JDBC解决方案)将从maven 4-5继承。
使用Spring MVC(“big Spring”的一部分)进行web开发…它是“基于请求的”框架,有“请求vs组件”的圣战…由你决定
Spring是Enterprise JavaBeans (EJB)技术的一个很好的替代方案。它还具有web框架和web服务框架组件。
推荐文章
- 你能解释一下流的概念吗?
- 导致java.lang.VerifyError错误的原因
- 如何在Java中监控计算机的CPU、内存和磁盘使用情况?
- 如何设置超时在改造库?
- java lambda可以有一个以上的参数吗?
- HashMap -获取第一个键值
- 使用Jackson将JSON字符串转换为漂亮的打印JSON输出
- Android - SPAN_EXCLUSIVE_EXCLUSIVE跨度不能为零长度
- Javadoc @see或{@link}?
- 在准备语句中使用“like”通配符
- Android Eclipse -无法找到*.apk
- javac和Eclipse编译器之间的区别是什么?
- 工厂模式和策略模式之间的区别是什么?
- 在Java中使用正则表达式提取值
- 如何允许所有网络连接类型HTTP和HTTPS在Android(9)馅饼?