spring13-AspectJ

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 1. AspectJ1.1. AspectJ介绍AspectJ官网^4 AspectJ文档^1 1.1.1. pointcutspointcuts指的是程序中的某些链接点(某些时机),例如call(void Point.setX(int))表示:调用类Point的setX(int)方法时 pointcuts可以使用与或非表达式(||,&&,!)连接,比如 call(void Point.setX(int)) || call(void Point.setY(int)) pointcuts可以被定义为变量,如下面代码中的move() 123456pointcut move(): call(void FigureElement.setXY(int,int)) || call(void Point.setX(int)) || call(void Point.setY(int)) || call(void Line.setP1(Point)) || call(void Line.setP2(Point)); 当然pointcuts定义的时候还可以使用通配符,比如call(void Figure.make*(..))代表Figure的以make开头且返回值为void的方法(不关心参数)调用的时候。比如call(public * Figure.* (..))代表Figure的任何方法(不关心方法名,参数,返回值)调用的时候。     阅读全文
fightinggg's avatar
fightinggg 3月 31, 2022

Springfox使用

    阅读全文
fightinggg's avatar
fightinggg 1月 13, 2022

Java运行时分析工具

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Jpsjps 可以看到运行中的java进程 123sh-4.2$ jps370 xxx.jar180682 Jps Jcmdjcmd可以看到运行中的java进程以及参数 123sh-4.2$ jcmd370 /usr/local/xxx.jar config_path=xxx.yaml180773 sun.tools.jcmd.JCmd Jmapjmap是可以查看整个JVM内存的工具。     阅读全文
fightinggg's avatar
fightinggg 9月 24, 2021

Java异常原因及处理

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Java常见异常1234567891011classDiagram Object <|-- Throwable Throwable <|-- Error Throwable <|-- Exception Error <|-- OutOfMemoryError Error <|-- NoClassDefFoundError Error <|-- StackOverflowError Exception <|-- IOException Exception <|-- RuntimeException RuntimeException <|-- NullPointerException RuntimeException <|-- IndexOutOfBoundsException NoClassDefFoundError 异常原因处理     阅读全文
fightinggg's avatar
fightinggg 7月 21, 2021

发布Maven二方包到Github仓库

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 使用Github Packages Repository这里主要介绍Github packages搭建私服,这种方案上传和下载都需要使用token 步骤1访问地址 ,点击Generate new token 创建新的token,选择权限 write:packages     阅读全文
fightinggg's avatar
fightinggg 5月 22, 2021

springcloud-cluster

    阅读全文
fightinggg's avatar
fightinggg 12月 16, 2020

Java杂谈

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial JAVAIDEASpring Boot 启动命令行太长修改文件.idea/workspace.xml 12<component name="PropertiesComponent"> <property name="dynamic.classpath" value="true" />     阅读全文
fightinggg's avatar
fightinggg 12月 06, 2020

springcloud-gateway

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Spring Cloud Gateway12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697package com.example.demo;import java.util.ArrayList;import java.util.List;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.gateway.event.RefreshRoutesEvent;import org.springframework.cloud.gateway.route.RouteDefinition;import org.springframework.cloud.gateway.route.RouteDefinitionRepository;import org.springframework.context.ApplicationEventPublisher;import org.springframework.context.ApplicationEventPublisherAware;import org.springframework.web.bind.annotation.DeleteMapping;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.PutMapping;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RestController;import reactor.core.publisher.Flux;import reactor.core.publisher.Mono;// 动态路由// https://zhuanlan.zhihu.com/p/125018436@RestController@SpringBootApplicationpublic class DemoApplication implements RouteDefinitionRepository, ApplicationEventPublisherAware { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } // event publisher ApplicationEventPublisher applicationEventPublisher; @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; } // router List<RouteDefinition> memery = new ArrayList<>(); private void refreshRoute() { applicationEventPublisher.publishEvent(new RefreshRoutesEvent(this)); } @PutMapping Mono<Void> putRoute(@RequestBody Mono<RouteDefinition> o) { return o.flatMap(routeDefinition -> { memery.add(routeDefinition); refreshRoute(); return Mono.empty(); }); } @PostMapping Mono<Void> postRoute(@RequestBody Mono<RouteDefinition> o) { return o.flatMap(routeDefinition -> { for (int i = 0; i < memery.size(); i++) { if (memery.get(i).getId().equals(routeDefinition.getId())) { memery.set(i, routeDefinition); } } refreshRoute(); return Mono.empty(); }); } @DeleteMapping Mono<Void> deleteRoute(@RequestBody Mono<String> o) { return o.flatMap(id -> { memery.removeIf(routeDefinition -> routeDefinition.getId().equals(id)); refreshRoute(); return Mono.empty(); }); } @GetMapping Mono<List<RouteDefinition>> getRoute(){ return Mono.just(memery); } @Override public Flux<RouteDefinition> getRouteDefinitions() { return Flux.fromIterable(memery); } @Override public Mono<Void> save(Mono<RouteDefinition> route) { return Mono.empty(); } @Override public Mono<Void> delete(Mono<String> routeId) { return Mono.empty(); }}     阅读全文
fightinggg's avatar
fightinggg 11月 10, 2020

aware

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial AwareBeanNameAwarebeanNameAware可以获得容器中Bean的名称,作用于每一个Bean。当bean被创建的时候设置他的名字,在基本properties填充完成以后,init调用前执行 摘自: spring-beans:5.3.4 org.springframework.beans.factory.BeanNameAware Set the name of the bean in the bean factory that created this bean. Invoked after population of normal bean properties but before an init callback such as {@link InitializingBean#afterPropertiesSet()} or a custom init-method. 123456789101112package com.example.demo;import org.springframework.beans.factory.BeanNameAware;import org.springframework.stereotype.Component;@Componentpublic class BeanNameAwareDemo implements BeanNameAware { @Override public void setBeanName(String name) { System.out.println(name); }}     阅读全文
fightinggg's avatar
fightinggg 11月 03, 2020

feign

    阅读全文
fightinggg's avatar
fightinggg 11月 01, 2020