Spring Cloude 之Ribbon的基本应用

一、 Ribbon简介

Ribbon是Netflix发布的负载均衡器,它有助于控制HTTP和TCP的客户端的行为。为Ribbon配置服务提供者地址后,Ribbon就可基于某种负载均衡算法,自动地帮助服务消费者去请求。Ribbon默认为我们提供了很多负载均衡算法,例如轮询、随机等。当然,我们也可为Ribbon实现自定义的负载均衡算法。

在Spring Cloud中,当Ribbon与Eureka配合使用时,Ribbon可自动从Eureka Server获取服务提供者地址列表,并基于负载均衡算法,请求其中一个服务提供者实例。展示了Ribbon与Eureka配合使用时的架构。

二、新建一个Eureka服务注册项目 springcloud-deepeureka

2.1、pom.xml依赖


  4.0.0

  cn.com.qihang.cloud
  springcloud-deepeureka
  0.0.1-SNAPSHOT
  jar

  springcloud-deepeureka
  http://maven.apache.org

        org.springframework.boot
        spring-boot-starter-parent
        1.5.9.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
    
    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                Edgware.RELEASE
                pom
                import
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    



2.2、启动类

@SpringBootApplication
@EnableEurekaServer
public class DeppEurekaApplication 
{
    public static void main( String[] args )
    {
        SpringApplication.run(DeppEurekaApplication.class, args);
    }
}

2.3、application.yml配置

server:
  port: 8081
eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8081/eureka/

项目结构

Spring Cloude 之Ribbon的基本应用_第1张图片

三、 新建springcloud-ribbon项目

3.1、pom.xml依赖


	4.0.0

	cn.com.qihang.cloud
	springcloud-ribbon
	0.0.1-SNAPSHOT
	jar

	springcloud-ribbon
	http://maven.apache.org
	
		org.springframework.boot
		spring-boot-starter-parent
		1.5.9.RELEASE
		
	

	
		UTF-8
		UTF-8
		1.8
	
	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				Edgware.RELEASE
				pom
				import
			
		
	
	

		
			org.springframework.boot
			spring-boot-starter-web
		


		
			org.springframework.cloud
			spring-cloud-starter-eureka
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		
	
	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	


3.2、启动类: 为RestTemplate添加注解@LoadBalanced

@SpringBootApplication
@EnableEurekaClient
//@RibbonClient(name = "springcloud-user")
public class ConsumerRibbonApplication {

  @Bean
  @LoadBalanced
  public RestTemplate restTemplate() {
    return new RestTemplate();
  }

  public static void main(String[] args) {
    SpringApplication.run(ConsumerRibbonApplication.class, args);
  }
}

3.3、测试数据实体User类

public class User {
  private Long id;

  private String username;

  private String name;

  private Short age;

  private BigDecimal balance;

  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getUsername() {
    return this.username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Short getAge() {
    return this.age;
  }

  public void setAge(Short age) {
    this.age = age;
  }

  public BigDecimal getBalance() {
    return this.balance;
  }

  public void setBalance(BigDecimal balance) {
    this.balance = balance;
  }

}

3.4、新建Controller访问

@RestController
public class RibbonController {
  @Autowired
  private RestTemplate restTemplate;
  @Autowired
  private LoadBalancerClient loadBalancerClient;

  @GetMapping("/user/{id}")
  public User findById(@PathVariable Long id) {
    // http://localhost:7900/simple/
    // VIP virtual IP
    // HAProxy Heartbeat
    return this.restTemplate.getForObject("http://springcloud-user/simple/" + id, User.class);
  }

  @GetMapping("/test")
  public String test() {
    ServiceInstance serviceInstance = this.loadBalancerClient.choose("springcloud-user");
    System.out.println("111" + ":" + serviceInstance.getServiceId() + ":" + serviceInstance.getHost() + ":" + serviceInstance.getPort());

    ServiceInstance serviceInstance2 = this.loadBalancerClient.choose("springcloud-user2");
    System.out.println("222" + ":" + serviceInstance2.getServiceId() + ":" + serviceInstance2.getHost() + ":" + serviceInstance2.getPort());

    return "1";
  }
}

3.5、application.yml配置

server:
  port: 8010
spring:
  application:
    name: springcloud-ribbon
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8081/eureka/
  instance:
    prefer-ip-address: true

springcloud-ribbon项目结构

Spring Cloude 之Ribbon的基本应用_第2张图片

四、新建一个数据提供服务项目springcloud-user

4.1、pom.xml依赖


  4.0.0

  cn.com.qihang.cloud
  springcloud-user
  0.0.1-SNAPSHOT
  jar

  springcloud-user
  http://maven.apache.org

		org.springframework.boot
		spring-boot-starter-parent
		1.5.9.RELEASE
		
	

	
		UTF-8
		UTF-8
		1.8
	
	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				Edgware.RELEASE
				pom
				import
			
		
	
	
		
			org.springframework.boot
			spring-boot-starter-data-jpa
		
		
			org.springframework.boot
			spring-boot-starter-web
		

		
			com.h2database
			h2
			runtime
		
		
			org.springframework.cloud
			spring-cloud-starter-eureka
		
		
			org.springframework.cloud
			spring-cloud-starter-eureka-server
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	


4.2、实体数据对象类

@Entity
public class User {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;

  @Column
  private String username;

  @Column
  private String name;

  @Column
  private Short age;

  @Column
  private BigDecimal balance;

  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getUsername() {
    return this.username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Short getAge() {
    return this.age;
  }

  public void setAge(Short age) {
    this.age = age;
  }

  public BigDecimal getBalance() {
    return this.balance;
  }

  public void setBalance(BigDecimal balance) {
    this.balance = balance;
  }
}

4.3、新建Repository数据库访问层


@Repository
public interface UserRepository extends JpaRepository {

}

4.4、新建Controller访问请求层

@RestController
public class UserController {

  @Autowired
  private UserRepository userRepository;

  @GetMapping("/simple/{id}")
  public User findById(@PathVariable Long id) {
    return this.userRepository.findOne(id);
  }
}

4.5、application.yml配置

server:
  port: 7900
spring:
  jpa:
    generate-ddl: false
    show-sql: true
    hibernate:
      ddl-auto: none
  datasource:
    platform: h2
    schema: classpath:schema.sql
    data: classpath:data.sql
  application:
    name: springcloud-user
logging:
  level:
    root: INFO
    org.hibernate: INFO
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE
    org.hibernate.type.descriptor.sql.BasicExtractor: TRACE
    com.itmuch: DEBUG
eureka:
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: http://localhost:8081/eureka
  instance:
    prefer-ip-address: true

4.6、schema.sql数据库

drop table user if exists;
create table user(
	id bigint generated by default as identity,
	username varchar(40),
	name varchar(20),
	age int(3),
	balance decimal(10,2), 
	primary key(id)
);

4.7、data.sql数据

insert into user(id,username, name, age, balance) values(1,'user1', '张三', 20, 100.00);
insert into user(id,username, name, age, balance) values(2,'user2', '李四', 20, 100.00);
insert into user(id,username, name, age, balance) values(3,'user3', '王五', 20, 100.00);
insert into user(id,username, name, age, balance) values(4,'user4', '马六', 20, 100.00);

springcloud-user项目结构

Spring Cloude 之Ribbon的基本应用_第3张图片

五、测试: 依次启动项目

  • 启动微服务Eureka项目:springcloud-deepeureka
  • 启动ribbon微服务:springcloud-ribbon
  • 启动user数据提供微服务:springcloud-user

六、访问Eureka服务测试

Spring Cloude 之Ribbon的基本应用_第4张图片

七、通过访问Ribbon负载分流服务测试查看访问数据

Spring Cloude 之Ribbon的基本应用_第5张图片

springcloud-user项目控制台打印结果

2019-09-07 17:26:23.662  INFO 16440 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-09-07 17:28:28.427  INFO 16440 --- [nio-7900-exec-3] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-09-07 17:28:28.428  INFO 16440 --- [nio-7900-exec-3] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-09-07 17:28:28.454  INFO 16440 --- [nio-7900-exec-3] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 26 ms
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:28:28.537 TRACE 16440 --- [nio-7900-exec-3] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:28:28.547 TRACE 16440 --- [nio-7900-exec-3] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:28:28.547 TRACE 16440 --- [nio-7900-exec-3] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:28:28.549 TRACE 16440 --- [nio-7900-exec-3] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:28:28.549 TRACE 16440 --- [nio-7900-exec-3] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]

八、测试负载均衡分流

8.1、修改user服务项目的配置文件中的端口

server:
 port: 7909  ## 修改端口
spring:
  jpa:
    generate-ddl: false
    show-sql: true
    hibernate:
      ddl-auto: none
  datasource:
    platform: h2
    schema: classpath:schema.sql
    data: classpath:data.sql
  application:
    name: springcloud-user
logging:
  level:
    root: INFO
    org.hibernate: INFO
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE
    org.hibernate.type.descriptor.sql.BasicExtractor: TRACE
    com.itmuch: DEBUG
eureka:
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: http://localhost:8081/eureka
  instance:
    prefer-ip-address: true

8.2、在启动一个user数据提供服务:启动方式如下

Spring Cloude 之Ribbon的基本应用_第6张图片

8.3、启动两个user服务后,再次访问Eureka服务查看

Spring Cloude 之Ribbon的基本应用_第7张图片

8.4、多次重复请求ribbon服务提供的数据请求访问路径

访问http://localhost:8010/user/1 ,可以得出ribbon默认采用轮询的方式进行负载均衡

Spring Cloude 之Ribbon的基本应用_第8张图片

8.5、通过切换两个user数据服务查看访问分流情况

Spring Cloude 之Ribbon的基本应用_第9张图片

名为springCloudUserApplication服务请求的情况

2019-09-07 17:31:23.680  INFO 16440 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-09-07 17:36:23.698  INFO 16440 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-09-07 17:41:23.716  INFO 16440 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:06.811 TRACE 16440 --- [nio-7900-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:06.812 TRACE 16440 --- [nio-7900-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:06.812 TRACE 16440 --- [nio-7900-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:06.812 TRACE 16440 --- [nio-7900-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:06.813 TRACE 16440 --- [nio-7900-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:12.432 TRACE 16440 --- [nio-7900-exec-6] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:12.432 TRACE 16440 --- [nio-7900-exec-6] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:12.432 TRACE 16440 --- [nio-7900-exec-6] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:12.432 TRACE 16440 --- [nio-7900-exec-6] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:12.433 TRACE 16440 --- [nio-7900-exec-6] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:18.502 TRACE 16440 --- [io-7900-exec-10] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:18.502 TRACE 16440 --- [io-7900-exec-10] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:18.502 TRACE 16440 --- [io-7900-exec-10] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:18.502 TRACE 16440 --- [io-7900-exec-10] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:18.503 TRACE 16440 --- [io-7900-exec-10] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:22.694 TRACE 16440 --- [nio-7900-exec-1] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:22.694 TRACE 16440 --- [nio-7900-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:22.694 TRACE 16440 --- [nio-7900-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:22.694 TRACE 16440 --- [nio-7900-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:22.694 TRACE 16440 --- [nio-7900-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:24.342 TRACE 16440 --- [nio-7900-exec-5] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:24.342 TRACE 16440 --- [nio-7900-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:24.342 TRACE 16440 --- [nio-7900-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:24.342 TRACE 16440 --- [nio-7900-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:24.343 TRACE 16440 --- [nio-7900-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:25.668 TRACE 16440 --- [nio-7900-exec-9] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:25.669 TRACE 16440 --- [nio-7900-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:25.669 TRACE 16440 --- [nio-7900-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:25.669 TRACE 16440 --- [nio-7900-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:25.669 TRACE 16440 --- [nio-7900-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:26.976 TRACE 16440 --- [nio-7900-exec-8] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:26.977 TRACE 16440 --- [nio-7900-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:26.977 TRACE 16440 --- [nio-7900-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:26.977 TRACE 16440 --- [nio-7900-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:26.977 TRACE 16440 --- [nio-7900-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
2019-09-07 17:46:23.734  INFO 16440 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration

名为7909服务请求的情况

2019-09-07 17:38:49.254  INFO 18248 --- [           main] c.c.q.cloud.SpringCloudUserApplication   : Started SpringCloudUserApplication in 10.462 seconds (JVM running for 10.895)
2019-09-07 17:42:09.715  INFO 18248 --- [nio-7909-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-09-07 17:42:09.716  INFO 18248 --- [nio-7909-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-09-07 17:42:09.744  INFO 18248 --- [nio-7909-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:09.814 TRACE 18248 --- [nio-7909-exec-1] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:09.838 TRACE 18248 --- [nio-7909-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:09.839 TRACE 18248 --- [nio-7909-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:09.840 TRACE 18248 --- [nio-7909-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:09.840 TRACE 18248 --- [nio-7909-exec-1] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:14.344 TRACE 18248 --- [nio-7909-exec-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:14.346 TRACE 18248 --- [nio-7909-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:14.346 TRACE 18248 --- [nio-7909-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:14.346 TRACE 18248 --- [nio-7909-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:14.346 TRACE 18248 --- [nio-7909-exec-2] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:21.396 TRACE 18248 --- [nio-7909-exec-4] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:21.397 TRACE 18248 --- [nio-7909-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:21.397 TRACE 18248 --- [nio-7909-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:21.397 TRACE 18248 --- [nio-7909-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:21.397 TRACE 18248 --- [nio-7909-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:23.566 TRACE 18248 --- [nio-7909-exec-8] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:23.566 TRACE 18248 --- [nio-7909-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:23.566 TRACE 18248 --- [nio-7909-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:23.567 TRACE 18248 --- [nio-7909-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:23.567 TRACE 18248 --- [nio-7909-exec-8] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:25.025 TRACE 18248 --- [nio-7909-exec-5] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:25.026 TRACE 18248 --- [nio-7909-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:25.026 TRACE 18248 --- [nio-7909-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:25.026 TRACE 18248 --- [nio-7909-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:25.026 TRACE 18248 --- [nio-7909-exec-5] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
Hibernate: select user0_.id as id1_0_0_, user0_.age as age2_0_0_, user0_.balance as balance3_0_0_, user0_.name as name4_0_0_, user0_.username as username5_0_0_ from user user0_ where user0_.id=?
2019-09-07 17:42:26.284 TRACE 18248 --- [nio-7909-exec-9] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [1]
2019-09-07 17:42:26.284 TRACE 18248 --- [nio-7909-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([age2_0_0_] : [SMALLINT]) - [20]
2019-09-07 17:42:26.284 TRACE 18248 --- [nio-7909-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([balance3_0_0_] : [NUMERIC]) - [100.00]
2019-09-07 17:42:26.284 TRACE 18248 --- [nio-7909-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([name4_0_0_] : [VARCHAR]) - [张三]
2019-09-07 17:42:26.284 TRACE 18248 --- [nio-7909-exec-9] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([username5_0_0_] : [VARCHAR]) - [user1]
2019-09-07 17:43:48.956  INFO 18248 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-09-07 17:48:48.975  INFO 18248 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration

你可能感兴趣的:(Spring,Cloud)