Construction of high-performance micro-services system

A: basic applications Spring of
1: Create a web project, the spring four basic packet replication lib directory
Here Insert Picture Description
2: create a package, and create an interface in the packet, the interface methods defined in the
Here Insert Picture Description
3: Create a class that implements the interface, the methods class implements an interface, and write output statement
Here Insert Picture Description
4: create a profile applicationContext.xml, and create an id userDao of Bean in the configuration file
Here Insert Picture Description
5: create a test class TestIoC ,, and in main () method, initialize spring container , loading a configuration file, acquired through the container userDao example, say the last call instance () method
Here Insert Picture Description
6: test
Here Insert Picture Description
Here Insert Picture Description
two: spring boot integrated servlet and JSP
. 1: Review pom.xml file, add the following:
Here Insert Picture Description
2: update maven item
3: write servlet class (inherited the HttpServlet)
Here Insert Picture Description
. 4, add annotations servlet startup class
Here Insert Picture Description
5, after the above steps, the parameters can be passed by way of the URL in the java class.
6, Java parameters are passed to the JSP, JSP added application.properties stored in the path
Here Insert Picture Description
7, to create a path
Here Insert Picture Description
8, creating class contorl
Here Insert Picture Description
9, to create an entity class User Right source get and set
Here Insert Picture Description

10, create a jsp page, the same name must return to the contor class inside strings.

Here Insert Picture Description
11. JSP value verification pass
Here Insert Picture Description
three: spring framework outlined advantages of
advantages:

  1. Provides a method of managing an object, the object may be the intermediate layer effectively organized.
  2. Using a hierarchical structure, it may be incrementally introduced into the project.
  3. 有利于面向接口编程习惯的养成。
  4. 目的之一是为了写出易于测试的代码。
  5. 非侵入性,应用程序对Spring API的依赖可以减至最小限度。
  6. 一致的数据访问介面。
  7. 降低Java EE API的使用难度。
    缺点:
  8. 中断了应用程序的逻辑,使代码变得不完整,不直观。此时单从Source无法完全把握应用的所有行为。
  9. 将原本应该代码化的逻辑配置化,增加了出错的机会以及额外的负担.
    3.调试阶段不直观,后期的bug对应阶段,不容易判断问题所在。
    四:简述loC和DI
    IoC – Inversion of control, 控制反转。在Java开发中,IoC意味着将你设计好的对象交给容器控制,而不是传统的在你的对象内部直接控制。通俗的讲IoC是一种让服务消费者不直接依赖于服务提供者的组件设计方式,是一种减少类与类之间依赖的设计原则。
    IoC理解:
    1、应用程序无需主动new对象;而是描述对象应该如何被创建即可,IoC容器帮你创建,即被动实例化;
    2、应用程序不需要主动装配对象之间的依赖关系,而是描述需要哪个服务,IoC容器会帮你装配,被动接受装配;
    3、主动变被动,以前创建对象、装配对象的依赖关系都是由应用程序主动完成,现在变成被动了由IoC容器来完成;
    4、应用程序不知道依赖的具体实现,只知道需要提供某类服务的对象,达到并松散耦合;
    5、是一种让服务消费者不直接依赖于服务提供者的组件设计方式,是一种减少类与类之间依赖的设计原则.
    DI – Dependency Injection,依赖注入。从应用程序的角度来说,即组件之间的依赖关系由容器在运行期决定,形象的来说,即由容器动态的将某种依赖关系注入到组件之中. 依赖注入的目标并非为软件系统带来更多的功能,而是为了提升组件重用的概率,并为系统搭建一个灵活、可扩展的平台。通过依赖注入机制,我们只需要通过简单的配置,而无需任何代码就可指定目标需要的资源,完成自身的业务逻辑,而不用关心具体的资源来自何处、由谁实现.
    Ioc/DI的基本思想:
    1, the procedure to remove the dependencies between
    2, arranged to set the program object IoC / DI container, as a unified management Bean to
    3, the IoC / DI container to manage the created Bean, examples of
    4, the IoC / DI container to the relationship between these relationships Bean injected into objects which require
    short: is the dependency relationship between objects all removed by IoC / DI container to manage dependencies between the objects and object, to achieve Loose coupling between objects.

Guess you like

Origin blog.csdn.net/weixin_43853006/article/details/90579655