In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
IT technology is developing so fast that it is like a wave after wave, coming at you head on. If you are not careful, you will be swept to the bottom of the sea without turning over. We must learn to grasp those immutable essence or laws. Only in this way can we stand the tide without falling down, ride the wind and waves, and be a tide rider in this era of great changes!
In 2003, Rod Johnson founded Spring, and I started my graduate internship in that year. Participated in the work in 2005, the communications industry, the main development language is Cpicket +. After messing with JSP during my work-study program, I began to teach myself Spring to build personal websites around 2005. At that time, the hottest combination of development frameworks in the Java field was: Struts + Spring + Hibernate,SSH. In 2009, I moved to the mobile Internet industry, and the main development language gradually changed to Java. In 2014, I moved into the Internet finance industry again, customizing the internal development framework based on the Spring extension, from a Spring user to an extension developer. In 2016, I worked with Pivotal, the owner of Spring, for participating in the construction of an internal cloud platform. With the rise of technologies such as microservices, I have done a lot of Spring Boot\ Spring Cloud extension customization and training promotion in recent years.
Fifteen years have passed, starting from the lightweight development framework that replaced EJB, to the extremely powerful ecosystem, and then to Spring Boot\ Spring Cloud reshaping as the preferred framework in the field of cloud native application development. Spring is no longer what it used to be, and there have been numerous changes in it, but the only thing that remains unchanged is that it remains at the top of the Java development framework. Perhaps most readers are familiar with the use of Spring, but do you know the core technologies behind it? What major changes have taken place in it over the years? What is the reason for its evolution to Spring Boot/Spring Cloud? What are the key product design concepts that contribute to its success? . To be familiar with the use of Spring is only to "know what it is", and only by "knowing why" can we really make good use of it. Come on, don't miss it! Veterans use the experience of blood and sweat to analyze the invariants in the changing situation for you:
The core technology behind Spring
The course of evolution and development of Spring
Spring Cloud butterfly transformation and rebirth
Product Design concept of Spring
Product Promotion Strategy of Spring
.
Readable people: development, testing, architecture, products, etc.
1. The core technology behind Spring
Java EE or J2EE, short for Java Platform Enterprise Edition, is a set of specifications and standards for developing distributed enterprise applications, which consists of a set of services (Services), application program interfaces (APIs) and protocols. The following are 13 technical specifications covered by J2EE:
JDBC:Java Database Connectivity
JNDI:Java Naming and Directory Interface
EJB:Enterprise Java Bean
RMI:Remote Method Invocation
Java IDL for CORBA
JSP:Java Server Pages
Java Servlet
XML:Extensible Markup Language
JMS:Java Message Service
JTA:Java Transaction API
JTS:Java Transaction Service
Java Mail
JAF:JavaBeans Activation Framework
Productive forces determine the relations of production, while science and technology are the primary productive forces. Java is the first high-level programming language invented by Sun Microsystems, and EJB is also the J2EE standard specification implemented by Sun Microsystems, while Spring has replaced EJB as the de facto standard. From a secular point of view, this is a classic story of the weak defeating the strong. At that time, there were many well-known commercial companies behind EJB to provide strong support, and Spring is only Rod Johnson's personal ticket work, why the final outcome unexpected? In fact, the weak can not beat the strong, but at that time the world did not understand where Spring is stronger than EJB, now we go to analyze it and know that it is strong in technology, advanced technology has created the lightweight and easy to use of Spring, coupled with the open source free business model, and finally win users.
So which core technologies make Spring brilliant? In addition to the most famous control inversion IOC, dependency injection DI and aspect-oriented programming AOP, there are MVC, Taglib, ORM, Annotation, etc., as well as other J2EE standard specifications support, including: JDBC, JNDI, RMI, JMS, etc., then we briefly introduce these key technologies, if you want a more in-depth understanding, you can find materials to do project learning.
1.1 IOC / DI / AOP
As an open source framework, Spring is created by people to reduce the development complexity of enterprise applications, but now it is no longer limited to the field of enterprise applications, but a lightweight control inversion IoC (Inversion of Control) and aspect-oriented AOP (Aspect Oriented Programming) container framework. The application is loosely coupled through IoC technology, and the business logic and system services are separated by aspect-oriented programming. IoC container is responsible for managing the configuration and life cycle of all application objects, configuring and combining simple components into complex applications.
Another term for control inversion IoC is dependency injection DI (Dependency Injection), which regulates the assembly process between objects and dependent objects. Objects declare dependencies through constructor parameters, factory method parameters, and property setting functions. IoC container provides assembly and management Bean functions. The whole assembly process is controlled by IoC container scheduling. It injects the dependent instances in the process of creating object instances, which is contrary to the process that Bean controls initializing or locating dependent instances directly through the constructor or Service Locator mode.
The interface org.springframework.context.ApplicationContext represents the Spring IoC container, which is responsible for initializing, configuring, assembling, and managing all Bean. The IoC container obtains the instructions related to initialization, configuration and assembly by reading the configuration metadata in XML, annotations or Java classes. We use the above configuration method to describe the objects that make up the application and the dependencies between them. IoC/DI makes applications no longer strongly dependent on the framework, and can flexibly assemble applications with the help of configuration files, annotations, etc., the front-end Web framework has been replaced by countless models: Struts, Webwork, JSF, Tapestry, AngularJS, React, Vue, etc., persistence layer also has many options: Hibernate, iBatis, MyBatis, etc., but only Spring stands out in the assembly field.
From the point of view of assembly, Spring is non-intrusive to the business, and the business code does not rely on Spring, that is, divesting the Spring to change to a new framework or writing a set of assembly code by yourself, the original business code can be reused. The original purpose of IoC is to take full advantage of the polymorphism of OO to instance and assemble objects through configuration files rather than hard coding, thus providing flexibility to provide services for different customer scenarios.
AOP adds functions to the program dynamically without modifying the source code by means of static precompilation or runtime dynamic proxy. It gives a unique programming perspective, controls all processing links of the system in a faceted way, and provides elegant solutions for many business scenarios. For example, logging, performance statistics, security control, transaction handling, exception handling and other codes are separated from the business logic code, and the business code is not affected when these behaviors are modified.
1.2 MVC / MVP / MMVM
View (View): user interface, data display.
Controller (Controller): the business logic that processes the request, select the view display.
Model (Model): business logic and data, data preservation and access operations.
View accepts user operation instructions and transmits them to Controller.
After the Controller completes the business logic processing, the Model is required to change the state.
Model sends the new data to View, and the user gets updated feedback.
MVP mode changes the Controller in MVC to Presenter and changes the direction of communication at the same time.
The communication between each part is two-way.
View does not interact directly with Model, all through Presenter.
The View is very thin and does not contain any business logic, called a "passive view" (Passive View), which means there is no initiative, while the Presenter is very thick, where all the logic is deployed.
The MVVM mode renames Presenter to ViewModel, which is basically exactly the same as the MVP pattern. The only difference is that it uses two-way binding (data-binding): changes in View are automatically reflected in ViewModel and vice versa. React, Vue and others all adopt this model.
1.3 JDBC / ORM
Java Database connection JDBC (Java DataBase Connectivity) is a Java API used to execute SQL statements that provide unified access to a variety of relational databases:
Object-relational mapping ORM (Object Relational Mapping) is a technology used to realize the conversion between objects and different types of relational database data in object-oriented programming languages:
2. The course of evolution and development of Spring
In 2002, veteran elder brother I graduated from college, when J2EE and EJB were the most popular, many well-known companies in the industry (such as Sun Microsystems, Oracle, IBM, etc.) were promoting the development and landing of EJB-related technologies. Rod Johnson, an American who was a young man at that time, thought that EJB was too bloated and that not all projects were suited to the heavy-duty framework of EJB, and he firmly believed that there were other more elegant solutions. To test his ideas, Rod Johnson published a book, Expert one on one J2EE development without EJB, in October 2002, in which he analyzed some key flaws in the J2EE and EJB frameworks. Rod Johnson firmly believes that:
J2EE should become easier to use.
Interface-oriented (Interface) programming is better than class-oriented (Class) programming, which can greatly reduce complexity.
JavaBean provides a very good way to configure applications.
Object-oriented design is more important than any other implementation technology, including J2EE.
Checked exceptions are overused in Java, and the platform should not force you to catch exceptions when the system cannot recover from them.
Testability is very important, and platforms like Spring should help you make your code easier to test.
Using Spring should be a pleasure.
The user's application code should not rely on any Spring APIs.
Spring should not compete with the excellent solutions that already exist, but should integrate these third-party components openly.
At the same time, he proposes a lightweight solution based on ordinary Java class dependency injection, and takes an online seat reservation system as an example to demonstrate how to build a high-quality and scalable system without using EJB. In order to build this demo application, he wrote more than 30000 lines of infrastructure code, which are not widely referenced as the books are open source. Because the root package of the open source project is named: com.interface21, so people initially called this open source framework: Interface21, it is the predecessor of Spring, this is an unintentional willow story.
As Interface21 was recognized and used by more and more users, Rod Johnson had the courage and confidence to compete with EJB. Later, he started working full-time and released Spring Framework 1.0 final on March 24, 2004. At that time, the whole Spring is a complete project, all functions are included in this project, including the core control inversion IOC and aspect-oriented programming AOP, in addition to: JDBC, Mail, ORM, transactions, scheduled tasks, Spring MVC and other supporting functions.
Looking back today, Rod Johnson did one thing right, that is, it embraced open source and supported many third-party open source frameworks in Spring 1.x, such as Struts, Hibernate, iBatis, template engine, and so on. About 15 years from the birth of Spring to the present, it is exactly 15 years when the software open source movement is booming. With the help of the open source community and bringing together global contributors, Spring has formed an extremely powerful ecosystem and has the ability to compete with traditional software giants, while EJB has chosen to be closed.
2.1 Spring 1.x
Spring 1.x mainly meets the needs of large-scale development of enterprise applications at that time. At that time, the classic architecture of J2EE applications is hierarchical architecture: presentation layer, business layer, persistence layer, and the most popular combination is SSH:Struts, Spring, Hibernate. Spring 1.x only supports XML-based configurations, ensuring that user code is not dependent on Spring. Spring 1.x mainly includes the following functional modules: aop, beans, context, core, dao, ejb, jdbc, jndi, mail, metadata, orm, remoting, scheduling, transation, ui, util, validation, web and so on.
2.2 Spring 2.x
Compared with Spring 1.xMagol 2.x, there is not much change, mainly in 1.x based on the gradual enhancement, adding the following new functional modules: cache.ehcache, instrument, jca, jms, jmx, scripting, stereotype and so on.
The veteran feels that users are like sand in their hands, and the more tightly they grasp, the faster they leak. Spring advocates not binding users, business code does not rely on Spring, and can be migrated from Spring to other frameworks at any time. Spring's insistence on loose coupling makes more and more users transfer from EJB to its name. At a time when the momentum is booming, Spring 2.x launched support for Java Annotation. Although the annotation-based configuration has some implications for the user code, this feature makes it very convenient for the user to configure with the code, making it more intuitive and easy to maintain.
2.3 Spring 3.x
Spring integrates third-party open source components in a simple and adaptable way, with its own features becoming more and more abundant, and the ecosystem becoming more and more powerful, a single project project can no longer meet the requirements of development, maintenance and use. Spring 3.x disassembles a single project into multiple sub-projects, which makes it easy for users to choose as needed, unlike previous versions, which require the introduction of all modules regardless of whether they are used or not. Break up into parts, this change has brought a very great impact, Spring is not only the accumulation of functional modules, it began to standardize the integration of related technologies, which is conducive to building a larger ecology, but also more conducive to the acquisition of new users.
Why would you say that? Before Spring is a whole, whether users choose it or not is a relatively large technical decision, but now each component can be introduced separately, the scope of decision-making becomes smaller, the risk is reduced, and users can try it on a small scale first, reducing the difficulty for users to get on the bus. When the user uses the components of Spring, a connection is established with the user, which gives the user more opportunities to learn about Spring, thus affecting the user's choice of more components.
The Spring framework is decomposed into several components, which can provide basic support for different application architectures, including message, transaction management, persistence and front-end components. It includes not only Servlet-based 's Spring MVC front-end Web framework, but also responsive Web frameworks such as Spring WebFlux, which users can choose according to their needs.
In addition to supporting XML and Annotation configurations, Spring 3.x also extends configurations based on Java classes. Spring Framework adds Expression, Instructment, Tomcat, oxm and other components, while the original Web is subdivided into: Portlet, Servlet.
2.4 Spring 4.x
Along the direction of Spring 3.x componentization, 4.x continues to upgrade, and Spring Framework expands Groovy, Messaging, Webmvc, Tiles2, Websocket and other functional components. At the same time, Spring also has a main upgrade line is to adapt to the version of Java, full support for Java 8.0, support for Lambda expressions and so on. As the RESTful architectural style is adopted by more and more users, Spring 4.x also provides new annotated features such as RestController.
2.5 Spring 5.x
Spring 5.x keeps pace with the update and iteration of Java-related technologies, constantly adapts to the latest version of Java, and constantly reconstructs and optimizes its core framework code to support functional and responsive programming models. We say that history has its inevitable law. The warriors who killed dragons will eventually become evil dragons. With the upgrading and evolution in the past decade, Spring has become more and more powerful and complex at the same time. Once defeated by lightweight and easy-to-use features, EJB has now become as bloated as EJB. Can Spring break away from this inevitable law of history?
2.6 Spring Boot
Brother Bing joined the Spring camp from 2.x, during which he followed the upgrade and evolution of Spring, and was familiar with it, which was backed by about ten years of background knowledge and experience. But for newcomers who have just started the job, Spring is too big and too complicated. The improvement of any professional skills is inseparable from a long period of study and practice, but the reality tells us that new talents are the main force of application development in most enterprises. Whether Spring can adapt to the changing environment and meet the demands of these new forces will determine whether Spring can continue to sit firmly in the top position of the Java application development framework.
Brother Bing has promoted the micro-service architecture within the company in the past two years. There are many ways to implement micro-services, but the key is from the perspective of users. Now that the post-90s are the main developers, the complete Spring technology stack is too challenging for them, and they do not have enough motivation to learn such complicated technologies. At this time, we have to change from a technical perspective to a product perspective, understand what users really think, and make it easier for them to learn to use Spring.
At this critical point in time, Spring does not forget the original ideal and ambition, and returns to the starting point of lightweight, using the concept of convention-first configuration to encapsulate complexity and shield users from many implementation details. Just like the chip technology of computer is extremely complex, but ordinary users do not need to know much about electronic circuits to use it, and now newcomers do not need to know too much background knowledge to use Spring Boot to do development. This is our technical people generally lack of product thinking, often encounter with complex technical people, then awesome technology, if it can not be used by more users, it will eventually be eliminated. Product thinking is to look at the problem from the user's point of view and take one more step towards the user's direction. For such a large amount of Spring, this is tantamount to Nirvana regeneration.
Considering that each of us has different work and study conditions and different problems, the content of this article can not cover the problems encountered by everyone. You are welcome to leave messages and questions, and you are also welcome to follow the exchange and interaction of "IT veterans". Thank you!
The index of other articles in this series is as follows: analysis of Spring core technology and product concept (part two)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.