dtwave201807 Elastic-Job——分布式定时任务框架


@Consumes @Produces分别表示入参和出参数吗


可以这样讲。但是不是很到位。
是限定作用,类似于filter
consumes: 指定处理请求的提交内容类型(Content-Type),例如application/json, text/html;
produces: 指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回;

Elastic-Job——分布式定时任务框架

spring boot中使用@SpringBootApplication指定类为应用启动类,

自动扫描于当前类同级以及子包下的相应注解注册为spring beans,

在类中main方法中通过SpringApplication的run方法启动应用。

eg:

  1.  
    package com.lanhuigu;
  2.  
     
  3.  
    import org.springframework.boot.SpringApplication;
  4.  
    import org.springframework.boot.autoconfigure.SpringBootApplication;
  5.  
     
  6.  
    @SpringBootApplication
  7.  
    public class SpringBootApp {
  8.  
    public static void main( String[] args ) {
  9.  
    SpringApplication.run(SpringBootApp.class, args);
  10.  
    }
  11.  
    }

使用@SpringBootApplication注解,等价于同时使用@Configuration @EnableAutoConfiguration @ComponentScan

这三个注解的默认属性,同时,使用@SpringBootApplication也可以接合使用@EnableAutoConfiguration @ComponentScan。

其中@ComponentScan很有用,可以通过该注解指定扫描某些包下包含如下注解的均自动注册为spring beans:

@Component, @Service, @Repository, @Controller,@Entity等等。

eg:

  1.  
    package com.lanhuigu;
  2.  
     
  3.  
    import org.springframework.boot.SpringApplication;
  4.  
    import org.springframework.boot.autoconfigure.SpringBootApplication;
  5.  
    import org.springframework.context.annotation.ComponentScan;
  6.  
     
  7.  
    @SpringBootApplication
  8.  
    @ComponentScan(basePackages = {"com.lanhuigu","com.ghg"})// string[]
  9.  
    public class SpringBootApp {
  10.  
     
  11.  
    public static void main( String[] args ) {
  12.  
    SpringApplication.run(SpringBootApp.class, args);
  13.  
    }
  14.  
    }

1.什么是API网关?

    API网关是一个轻量的java http 接口组件,可无缝将普通的 Serive 方法转换成 http 接口。并从已下几点来达到提高开发效率与接口质量的目的。

  1. 去掉mvc控制器,将http请求直接无缝接入JAVA服务接口
  2. 统一出入参格式
  3. 统一异常规范
  4. 自动检测服务接口规范

猜你喜欢

转载自www.cnblogs.com/1023linlin/p/9296829.html
今日推荐