国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

SpringCloud(第 048 篇)使用AOP統(tǒng)一處理Web請求日志

Vixb / 1735人閱讀

SpringCloud(第 048 篇)使用AOP統(tǒng)一處理Web請求日志

-

一、大致介紹
1、AOP是Spring框架中的一個重要內容,它通過對既有程序定義一個切入點,然后在其前后切入不同的執(zhí)行內容,比如常見的有:打開數(shù)據(jù)庫連接/關閉數(shù)據(jù)庫連接、打開事務/關閉事務、記錄日志等;
2、基于AOP不會破壞原來程序邏輯,因此它可以很好的對業(yè)務邏輯的各個部分進行隔離,從而使得業(yè)務邏輯各部分之間的耦合度降低,提高程序的可重用性,同時提高了開發(fā)的效率。
二、實現(xiàn)步驟 2.1 添加 maven 引用包


    4.0.0

    springms-aop-weblog
    1.0-SNAPSHOT
    jar
    
    
        com.springms.cloud
        springms-spring-cloud
        1.0-SNAPSHOT
    
    
    
        
        
            org.springframework.boot
            spring-boot-starter-data-jpa
        

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

        
        
            com.h2database
            h2
            runtime
        

        
        
            org.springframework.boot
            spring-boot-starter-data-solr
        
    

2.2 添加應用配置文件(springms-aop-weblogsrcmainresourcesapplication.yml)
server:
  port: 8350
spring:
  application:
    name: springms-aop-weblog  #全部小寫
  jpa:
    generate-ddl: false
    show-sql: true
    hibernate:
      ddl-auto: none
  datasource:
    platform: h2
    schema: classpath:schema.sql
    data: classpath:data.sql
2.3 添加 H2 數(shù)據(jù)庫腳本(springms-aop-weblogsrcmainresourcesschema.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)
);
2.4 插入 H2 數(shù)據(jù)庫一些初始化數(shù)據(jù)(springms-aop-weblogsrcmainresourcesdata.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", "李四", 22, 100.00);
INSERT into user (id, username, name, age, balance) values (3, "user3", "王五", 24, 100.00);
INSERT into user (id, username, name, age, balance) values (4, "user4", "趙六", 26, 100.00);
INSERT into user (id, username, name, age, balance) values (5, "user5", "李逵", 27, 100.00);
INSERT into user (id, username, name, age, balance) values (6, "user6", "張遠", 10, 100.00);
INSERT into user (id, username, name, age, balance) values (7, "user7", "迪拜", 60, 100.00);
INSERT into user (id, username, name, age, balance) values (8, "user8", "哈士奇", 40, 100.00);
INSERT into user (id, username, name, age, balance) values (9, "user9", "關羽", 30, 100.00);
2.5 添加訪問底層數(shù)據(jù)模型的DAO接口(springms-aop-weblogsrcmainjavacomspringmscloudrepositoryUserRepository.java)
package com.springms.cloud.repository;

import com.springms.cloud.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository {

}
2.6 添加實體用戶類User(springms-aop-weblogsrcmainjavacomspringmscloudentityUser.java)
package com.springms.cloud.entity;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@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;
  }
}
2.7 添加Web層日志切面@Order(1)(springms-aop-weblogsrcmainjavacomspringmscloudcontrollerUserController.java)
package com.springms.cloud.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/****************************************************************************************
 實現(xiàn)AOP的切面主要有以下幾個要素:

 使用@Aspect注解將一個java類定義為切面類
 使用@Pointcut定義一個切入點,可以是一個規(guī)則表達式,比如下例中某個package下的所有函數(shù),也可以是一個注解等。
 根據(jù)需要在切入點不同位置的切入內容
 使用@Before在切入點開始處切入內容
 使用@After在切入點結尾處切入內容
 使用@AfterReturning在切入點return內容之后切入內容(可以用來對處理返回值做一些加工處理)
 使用@Around在切入點前后切入內容,并自己控制何時執(zhí)行切入點自身的內容
 使用@AfterThrowing用來處理當切入內容部分拋出異常之后的處理邏輯
 使用@Order(i)注解來標識切面的優(yōu)先級。i的值越小,優(yōu)先級越高
 ****************************************************************************************/


/****************************************************************************************
 執(zhí)行日志順序:

 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) ARGS : [1]
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) ARGS : [1]
 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=?
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) SPEND TIME : 42
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) SPEND TIME : 43

 總結:doBefore 方法先從優(yōu)先級到低優(yōu)先級依次執(zhí)行完,然后 doAfterReturning 方法從低優(yōu)先級到高優(yōu)先級依次執(zhí)行完;也就是進入從高到低,出來從低到高;
 ****************************************************************************************/


/**
 * Web層日志切面。
 *
 * @author hmilyylimh
 *
 * @version 0.0.1
 *
 * @date 2017/10/19
 *
 */
@Aspect
@Order(1)
@Component
public class WebLogHeadAspect {


    // private static final org.slf4j.Logger logger = LoggerFactory.getLogger(PreZuulFilter.class);

    private Logger logger = Logger.getLogger(getClass());

    ThreadLocal startTime = new ThreadLocal<>();

    private static final String PRE_TAG = "(Order(1))************** ";

    @Pointcut("execution(public * com.springms.cloud.controller..*.*(..))")
    public void webLog(){}

    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
        startTime.set(System.currentTimeMillis());

        // 接收到請求,記錄請求內容
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();

        // 記錄下請求內容
        logger.info(PRE_TAG + "(doBefore) URL : " + request.getRequestURL().toString());
        logger.info(PRE_TAG + "(doBefore) HTTP_METHOD : " + request.getMethod());
        logger.info(PRE_TAG + "(doBefore) IP : " + request.getRemoteAddr());
        logger.info(PRE_TAG + "(doBefore) CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
        logger.info(PRE_TAG + "(doBefore) ARGS : " + Arrays.toString(joinPoint.getArgs()));

    }

    @AfterReturning(returning = "ret", pointcut = "webLog()")
    public void doAfterReturning(Object ret) throws Throwable {
        // 處理完請求,返回內容
        logger.info(PRE_TAG + "(doAfterReturning) RESPONSE : " + ret);
        logger.info(PRE_TAG + "(doAfterReturning) SPEND TIME : " + (System.currentTimeMillis() - startTime.get()));
    }
}
2.8 添加Web層日志切面@Order(5)(springms-aop-weblogsrcmainjavacomspringmscloudcontrollerUserController.java)
package com.springms.cloud.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/****************************************************************************************
 實現(xiàn)AOP的切面主要有以下幾個要素:

 使用@Aspect注解將一個java類定義為切面類
 使用@Pointcut定義一個切入點,可以是一個規(guī)則表達式,比如下例中某個package下的所有函數(shù),也可以是一個注解等。
 根據(jù)需要在切入點不同位置的切入內容
 使用@Before在切入點開始處切入內容
 使用@After在切入點結尾處切入內容
 使用@AfterReturning在切入點return內容之后切入內容(可以用來對處理返回值做一些加工處理)
 使用@Around在切入點前后切入內容,并自己控制何時執(zhí)行切入點自身的內容
 使用@AfterThrowing用來處理當切入內容部分拋出異常之后的處理邏輯
 使用@Order(i)注解來標識切面的優(yōu)先級。i的值越小,優(yōu)先級越高
 ****************************************************************************************/

/****************************************************************************************
 執(zhí)行日志順序:

 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) ARGS : [1]
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) ARGS : [1]
 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=?
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) SPEND TIME : 42
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) SPEND TIME : 43

 總結:doBefore 方法先從優(yōu)先級到低優(yōu)先級依次執(zhí)行完,然后 doAfterReturning 方法從低優(yōu)先級到高優(yōu)先級依次執(zhí)行完;也就是進入從高到低,出來從低到高;
 ****************************************************************************************/


/**
 * Web層日志切面。
 *
 * @author hmilyylimh
 *
 * @version 0.0.1
 *
 * @date 2017/10/19
 *
 */
@Aspect
@Order(5)
@Component
public class WebLogFiveAspect {


    // private static final org.slf4j.Logger logger = LoggerFactory.getLogger(PreZuulFilter.class);

    private Logger logger = Logger.getLogger(getClass());

    ThreadLocal startTime = new ThreadLocal<>();

    private static final String PRE_TAG = "(Order(5))============== ";

    @Pointcut("execution(public * com.springms.cloud.controller..*.*(..))")
    public void webLog(){}

    @Before("webLog()")
    public void doBefore(JoinPoint joinPoint) throws Throwable {
        startTime.set(System.currentTimeMillis());

        // 接收到請求,記錄請求內容
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();

        // 記錄下請求內容
        logger.info(PRE_TAG + "(doBefore) URL : " + request.getRequestURL().toString());
        logger.info(PRE_TAG + "(doBefore) HTTP_METHOD : " + request.getMethod());
        logger.info(PRE_TAG + "(doBefore) IP : " + request.getRemoteAddr());
        logger.info(PRE_TAG + "(doBefore) CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
        logger.info(PRE_TAG + "(doBefore) ARGS : " + Arrays.toString(joinPoint.getArgs()));

    }

    @AfterReturning(returning = "ret", pointcut = "webLog()")
    public void doAfterReturning(Object ret) throws Throwable {
        // 處理完請求,返回內容
        logger.info(PRE_TAG + "(doAfterReturning) RESPONSE : " + ret);
        logger.info(PRE_TAG + "(doAfterReturning) SPEND TIME : " + (System.currentTimeMillis() - startTime.get()));
    }
}
2.9 添加用戶Web訪問層Controller(springms-aop-weblogsrcmainjavacomspringmscloudcontrollerUserController.java)
package com.springms.cloud.controller;

import com.springms.cloud.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.springms.cloud.repository.UserRepository;

/**
 * 用戶微服務Controller。
 *
 * @author hmilyylimh
 *
 * @version 0.0.1
 *
 * @date 2017/10/19
 *
 */
@RestController
public class AopWebLogController {

    @Autowired
    private UserRepository userRepository;

    @GetMapping("/simple/{id}")
    public User findById(@PathVariable Long id) {
        return this.userRepository.findOne(id);
    }
}
2.10 添加微服務啟動類(springms-aop-weblogsrcmainjavacomspringmscloudMsAopWebLogApplication.java)
package com.springms.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 使用AOP統(tǒng)一處理Web請求日志。
 *
 * @author hmilyylimh
 *
 * @version 0.0.1
 *
 * @date 2017/10/19
 *
 */
@SpringBootApplication
public class MsAopWebLogApplication {

    public static void main(String[] args) {
        SpringApplication.run(MsAopWebLogApplication.class, args);
        System.out.println("【【【【【【 AopWebLog微服務 】】】】】】已啟動.");
    }
}
三、測試
/****************************************************************************************
 一、簡單用戶微服務類(實現(xiàn)AOP的切面打印日志):

 1、啟動 springms-aop-weblog 模塊服務,啟動1個端口;
 2、在瀏覽器輸入地址 http://localhost:8350/simple/1 可以看到日志信息成功的被打印出來到控制臺上。;

 執(zhí)行日志順序:

 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.810  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doBefore) ARGS : [1]
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) URL : http://localhost:8350/simple/1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) HTTP_METHOD : GET
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) IP : 127.0.0.1
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) CLASS_METHOD : com.springms.cloud.controller.SimpleProviderUserAopWebLogController.findById
 2017-10-19 20:22:35.811  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doBefore) ARGS : [1]
 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=?
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] com.springms.cloud.aop.WebLogFiveAspect        : (Order(5))============== (doAfterReturning) SPEND TIME : 42
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) RESPONSE : User@1249202
 2017-10-19 20:22:35.853  INFO 9014 --- [nio-8350-exec-1] WebLogHeadAspect    : (Order(1))************** (doAfterReturning) SPEND TIME : 43

 總結:doBefore 方法先從優(yōu)先級到低優(yōu)先級依次執(zhí)行完,然后 doAfterReturning 方法從低優(yōu)先級到高優(yōu)先級依次執(zhí)行完;也就是進入從高到低,出來從低到高;
 ****************************************************************************************/
四、下載地址

https://gitee.com/ylimhhmily/SpringCloudTutorial.git

SpringCloudTutorial交流QQ群: 235322432

SpringCloudTutorial交流微信群: 微信溝通群二維碼圖片鏈接

歡迎關注,您的肯定是對我最大的支持!!!

文章版權歸作者所有,未經(jīng)允許請勿轉載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/67834.html

相關文章

  • 這次要是講不明白Spring Cloud核心組件,那我就白編這故事了

    摘要:我不聽,我就是這么命名。任何服務啟動以后,都會把自己注冊到的注冊表中當服務死亡的時候,也會通知。服務拿到結果后,會把結果緩存在本地的注冊表里。根據(jù)負載均衡策略,從注冊表中選擇一個真正的實例地址。 原創(chuàng):小姐姐味道(微信公眾號ID:xjjdog),歡迎分享,轉載請保留出處。 這幾天可真是熱啊,泡個海澡是再好不過了。玩的正起勁,突然腳底絆上一股暗流,然后我就一直在水里旋轉旋轉旋轉...終于...

    stdying 評論0 收藏0
  • Java后端

    摘要:,面向切面編程,中最主要的是用于事務方面的使用。目標達成后還會有去構建微服務,希望大家多多支持。原文地址手把手教程優(yōu)雅的應用四手把手實現(xiàn)后端搭建第四期 SpringMVC 干貨系列:從零搭建 SpringMVC+mybatis(四):Spring 兩大核心之 AOP 學習 | 掘金技術征文 原本地址:SpringMVC 干貨系列:從零搭建 SpringMVC+mybatis(四):Sp...

    joyvw 評論0 收藏0
  • SpringCloud 012 )微服務接入 Feign 負載均衡通過 FeignClient

    摘要:添加電影微服務啟動類電影微服務接入進行客戶端負載均衡,通過調用遠程微服務。注解表示該電影微服務已經(jīng)接入模塊。 SpringCloud(第 012 篇)電影微服務接入 Feign 進行客戶端負載均衡,通過 FeignClient 調用遠程 Http 微服務 - 一、大致介紹 1、本章節(jié)主要介紹在 SpringCloud 生態(tài)圈中,使用一個類似于 Java HTTP 客戶端的工具 Feig...

    Cobub 評論0 收藏0
  • Spring aop+自定義注解統(tǒng)一記錄用戶行為日志

    摘要:自定義注解新增日志注解類,注解作用于方法級別,運行時起作用。自定義注解,聲明一種行為,使配置簡化,代碼層面更加簡潔。 showImg(https://segmentfault.com/img/remote/1460000017791628); 寫在前面 本文不涉及過多的Spring aop基本概念以及基本用法介紹,以實際場景使用為主。 場景 我們通常有這樣一個需求:打印后臺接口請求的具...

    haobowd 評論0 收藏0
  • 慕課網(wǎng)_《SpringBoot進階之Web進階》學習總結

    摘要:時間年月日星期日說明本文部分內容均來自慕課網(wǎng)。慕課網(wǎng)教學示例源碼個人學習源碼第一章課程介紹課程介紹本課程緊接著小時學會課程,請先看入門課。異常返回通知在連接點拋出異常后執(zhí)行。 時間:2017年3月19日星期日說明:本文部分內容均來自慕課網(wǎng)。@慕課網(wǎng):http://www.imooc.com教學示例源碼:https://github.com/zccodere/s...個人學習源碼:htt...

    lifefriend_007 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<