Whether to learn Springmvc

Source: Internet
Author: User

title, hope the heroes pointed out, can not use spring to think he is all right, this post is intended to work in practice, whether to introduce spring into the project and how to better use spring to provide heuristic advice. At present, there are people who express their dissatisfaction with spring, let me start to reflect, I hope you take this to spring's shortcomings to put forward their own views (and also some of the Company's interview questions).
I propose several points:
The use of 1,spring introduces a new level of complexity, which is beyond doubt (although it can reduce the complexity, it is a nightmare for small projects to introduce spring).
2, destroying some structures that should not have been destroyed, such as the complete abstraction of a class, now needs to be fully understood by looking at a configuration file or Annotation.
3, a single function test must start the spring container.
4, feeling the introduction of the spring project, it is difficult to break out of spring, I think spring is too close to the project coupling, like a strong skin plungers suction toilet mouth not release.

Instead of introducing the spring project, I chose spring for the schema Project.
Spring is a system that represents an architecture, and the IOC architecture, unlike Struts2 or jsf,
If you want to change it, you can change it.

Test of a single function do not have to start the spring container ah, you can write a public class to instantiate your class ah, with new can ah, but there is spring need to do so?

Annotation is used to simplify the spring configuration process.
You have not experienced the Spring2.0 stage, have you?
Do you know that the spring configuration file has 4 xml, 2000 rows per case?

Instead of introducing the spring project, I chose spring for the schema Project.
Spring is a system that represents an architecture, and the IOC architecture, unlike Struts2 or jsf,

Architecture is just an extension of the jdk, and from this point of view, Spring and other architectures are no different, Struts2 provides the MVC capability, Spring provides IOC and AOP capabilities, do you think?

If you want to change it, you can change it.

Test of a single function do not have to start the spring container ah, you can write a public class to instantiate your class ah, with new can ah, but there is spring need to do so?

Maybe the project is not the same, I am working on the project every function point needs to be tested, spring this kind of IOC and AOP ability let me test a point of time, also need to consider the configuration file, and in order to test a separate write configuration file, very strange, do not know what you have to Say.

Annotation is used to simplify the spring configuration process.
You have not experienced the Spring2.0 stage, have you?
Do you know that the spring configuration file has 4 xml, 2000 rows per case?

experienced, But there is no 2000 lines of quantity, divided some modules, each module configuration 300 line bar. I don't think annotation simplifies the configuration process, but makes the class Impure.

Recently interviewed a company, is one of the most domestic bar, asked all the shortcomings of XXX architecture, which has spring, the problem hangs, depressed, feel that their cultivation is not enough ah, the problem is not comprehensive, I hope you can guide Me.

If you break out of spring, the transaction with code processing, undoubtedly added a lot of code, and spring MVC is more convenient than struts2, as for testing, The purpose of the boot container is to load datasource bar, because the other you can be new out, Annotation simplifies many configurations when configuring spring or hibernate, But you can also continue to use Xml. As for what is called pure code, there is nothing to say, I do not recognize the code is mixed with the various XML is Pure.

well, the shortcomings, but also purely personal ideas, all elegant framework, will result in the loss of execution Efficiency. and add some uncertainty, can only think that it should execute the correct results, complex and changeable application scenarios, no one can guarantee that the framework will not have some hidden low-level bugs, can not fully control the robustness of the code, after all, people write out things. Speaking of this may be a rebuttal, he did not hit a bug, this time should monitor the operation of the virtual machine, such as the Web project in high concurrency situation, is not frequent gc, why this, want to solve but do not know. I do the original 12530 member interface time, encountered this problem, and later found that the same query pressure test, only with axis+jdbc case, than the average response time to use Spring+hibernate less, as to how to determine whether to do gc, is not here to discuss, I'm interested in talking to you privately.

What's more, The technical content of programmers is getting lower, and spring is not about your code, it's thinking. Seen some people left spirng, even a connection are not, more than a year of work experience, do not know what connection is what, from training to work contact are the framework, the teacher a few words with the basis of the meal to Eat. A small j2se daemon with hundreds of lines of valid code is bound to Spring.

As for what is said online does not support distributed applications, the lack of IDE support, and so on, are called Limitations.

Feel the company interview asked the framework of shortcomings, is to understand your use of the scene, and encountered unsatisfactory place, not nitpick, as if in the end should be used C3P0 or proxool, Why use a reason it. After all, a framework has developed for such a long time, pure defects can be perfected.

The use of 1,spring introduces a new level of complexity, which is beyond doubt (although it can reduce the complexity, it is a nightmare for small projects to introduce spring).

Is it necessary to use spring for small projects? In fact, the size, when you want to easily use certain features, such as ioc, cut-off, declarative transactions, and so on, you should use spring, you need so many spring can easily integrate and series functions, why not use spring?

of course, If the project does not use these features, it does not say that you must use Spring.


2, destroying some structures that should not have been destroyed, such as the complete abstraction of a class, now needs to be fully understood by looking at a configuration file or Annotation.

This is a common feature of the IOC container, of course, a good ide, such as IntelliJ idea: in refactoring, navigation, you will hardly feel the inconvenience of using Ioc.


3, a single function test must start the spring container.

The boot is slow, but using the spring JUnit Runner annotations on the encoding will not knock much more code.

4, feeling the introduction of the spring project, it is difficult to break out of spring, I think spring is too close to the project coupling, like a strong skin plungers suction toilet mouth not release.

The existence of spring can greatly reduce the coupling of the project itself, but spring differs from the framework applied to a particular domain.  It covers all aspects: mvc, transaction abstraction, Slice programming, task abstraction, security framework ...  But it is loosely coupled to each module as much as possible, and MVC can be used with struts, or its spring mvc,orm framework can be used by many brands ... I think there is no other framework to do it as loosely coupled.

Is there such a scenario as to replace spring itself?

Attached: another: Tools + IOC + MVC + DB + AOP + tx + HTML

Why is it a nightmare for small projects to introduce spring? How small are you talking about a project?
I think it's good to use spring as a factory for small projects.
How does it break the abstract structure? Unless you use Aop. otherwise, It is interface interaction and what is the relationship to spring Injection.
Annotation is a double-edged sword, excessive use and not all bad, this should be measured by themselves.
Can't get rid of spring because spring is a kind of factory, will you write your own factory again? Then you can get rid of the JDK No. no, It's a Tool.

There is no sense of what can replace Spring. Because spring includes all the content of the creation design pattern

Why SPRINGMVC is so good, there are a lot of companies in the new project with STRUTS2

1, the inland Internet industry is relatively underdeveloped, traditional IT companies have always valued business
2, the old system needs maintenance, no refactoring power
3, technology replacement requires courage and energy, depends on the Architect's wishes
4. After the more advanced technology comes out, like there will be a lot of people holding spring MVC do not let go, this is a cycle

5.STRUTS2 performance is not worse than springmvc, the drag is struts2 tag, ongl expression and so On. All say Springmvc than struts2 performance, but as long as not using Struts tag library performance is very good!

6.struts2 is Class-level interception, A class corresponds to a request context, Springmvc is a method-level intercept, a method corresponds to a request context, and the method corresponds to a url, So it's easy to implement restful URLs from the architecture itself, and Struts2 's architecture is SPRINGMVC because a method of action in Struts2 can correspond to a url, and its class properties are shared by all METHODS. It is also not possible to identify the method that it belongs to by annotations or other Means.
8. From the above reason, the Springmvc method is basically independent, the request response data, requests the data through the parameter acquisition, the processing result passes through the Modelmap to the frame, the method does not share the variable, but the Struts2 is engaged in the disorderly, Although the method is also independent, but all of its action variables are shared, which does not affect the program run, but it gives us the trouble of coding to read the program, each time a request to create an action, an action object corresponding to a request Context.
9. Because the STRUTS2 needs to be encapsulated for each request, the variables of the servlet life cycle such as request,session are encapsulated into a single map, supplied to each action and guaranteed to be thread safe, so in principle it is more Memory-intensive.
10. Interceptor Implementation mechanism, STRUTS2 has its own interceptor mechanism, SPRINGMVC with the independent AOP mode, which results in STRUTS2 configuration file volume is larger than springmvc.
The 11.SpringMVC entrance is the servlet, and Struts2 is the filter (it is noted here that the filter and servlet are Different.) It was thought that filter was a special kind of servlet, which led to a different mechanism between the two, which involved the difference between servlet and Filter.
12.SpringMVC integrates ajax, very convenient to use, just one annotation @responsebody can be implemented, and then directly return the response text, and the Struts2 interceptor integrates ajax, In action, it is generally necessary to install Plug-ins or write code to integrate them, it is relatively inconvenient to Use.

Whether to learn Springmvc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.