zoukankan      html  css  js  c++  java
  • spring in action 01

    环境搭建

    可以通过 eclipse -> help 菜单 -> Eclipse Marketplace, 然后选择 popular, 从中找到 Spring Tool Suite(STS)插件.

    这样就安装了 STS 插件, 可以方便引入 Spring Boot 的 starter, 而 starter 会引入对应的依赖包和服务器, 这样快速帮我们搭建环境.

    spring boot 可以不在使用 war 包来部署应用了.

    A new interest in reactive programming aims to provide greater scalability and improved proformance with non-blocking operations.

    传统方式

    当有这两个 service, (inventory service 和 product service), 传统方式是: xml 或 java bean

    <bean id="inventoryService"
    class="com.example.InventoryService" />
    <bean id="productService"
    class="com.example.ProductService" />
    <constructor-arg ref="inventoryService" />
    </bean>
    @Configuration
    public class ServiceConfiguration {
    @Bean
    public InventoryService inventoryService() {
    return new InventoryService();
    }
    @Bean
    public ProductService productService() {
    return new ProductService(inventoryService());
    }
    }

    The @Configuration annotation indicates to Spring that this is a configuration class that will provide beans to the Spring application context.

     Automatic configuration has its roots in the Spring techniques known as autowiring and component scanning. 

    component scanning: Spring can automatically discover components from an application's classpath and create them as beans.

    autowiring: Spring automatically injects the components with the other beans that they depend on.

    More recently, with introduction of Spring Boot, automatic configuration has gone well beyond component scanning and autowiring.

    Spring Boot, the most well-know, is autoconfiguration. (所以spring boot 就更近一步, 不用设置了)

  • 相关阅读:
    Miller-Rabin算法
    拟阵
    第一次作业
    实验四 201771010101 白玛次仁
    201771010101 白玛次仁
    201771010101 白玛次仁 《2018面向对象程序设计(Java)课程学习进度条》
    201771010101 白玛次仁
    201771010101 白玛次仁
    达拉草201771010105《面向对象程序设计(java)》第二周学习总结
    达拉草201771010105《面向对象程序设计(java)》第一周学习总结
  • 原文地址:https://www.cnblogs.com/moveofgod/p/12643891.html
Copyright © 2011-2022 走看看