I have read some spring information again, and some new understandings are available for Spring. Recall some Spring related programbar breaks that I have written, so I recorded some experience.
Note when using Spring:
First, don't be superstitious
The founder of the Spring project (we are great ... What do you do? Don't you fight, don't you tell you?) Also think the excellent design is far more important than use. So don't think that Spring can guarantee that our system has a non-bad body. However, domestic but often used a certain advanced technology as a signboard. I never believe that the project that uses a good technology will definitely be successful.
Second, due to question
Use different solutions for specific situations. Spring is definitely a good choice from an incomplete project, but for a project that already exists in the data structure or the old code, it can play it in the middle of it.
There are often two guys who use Hibernate and Struts simultaneously with Spring. Struts is not mentioned, after all, people fans, I am afraid to die. Hibernate is also a big guy who is holding a lot of people, but this is not universal. Hibernate is almost perfectly encapsulated in the underlying data synchronization, which can save us too much time in development. But the perfect itself is a shortcoming, and Hibernate is perfect, it is "performance" for perfect payment. Unbelievable Hibernate advocates can do a test to see how many times the operation after packaging is slower than JDBC programming methods. Package is perfect, you can't optimize your SQL statement, if your database is an existing, then use hibernate will only bring you endless trouble.
So before using it, you have a complexity of your system. If your system is very simple, there is not so much interdependent Bean, we don't have to use Spring.
Third, try to use the SET method's injection mode
I have seen a lot of Spring-related code, and the birth is basically divided into two types for BeanFactory, one is to acquire the BeanFactory instance and generate the required bean; the other is to use the SET method. Implementation.
I am strange to find that many people like to get the BeanFactory instance and then generate instances, I think this has violated the principle of Spring's usage - minimize the dependence between modules. So I think the injection mode of using the SET method is the correct choice, at least such a code looks more elegant.
Fourth, cautious choice SpringMVC as a performance layer
Spring is a good thing, but does not mean it all suits you. At least I think SpringMVC is not suitable for most situations, and Springmvc is very elegant, but its elegance is over. Just like an expert in theory and has a very high academic status, such experts do not necessarily be a master that can create a lot of value.
Springmvc has high learning costs, although powerful, but cannot be skilled. So I usually do not choose to use such a excessive focus on design, and the design should not be transitioned.