首页 文章 新番
动漫 学习 生活 日记 书籍 服务器 Bing
  • SQLServer备份还原注意

    新的公司用了好多数据库:es、neo4j、oracle、mysql、mssql。今天备份还原mssql头都被搞大了,还有安装oracle也是,主要是都是用的docker,以前没用过。还原mssql一直提示:```Msg102,Level15,State1,Server9cd172370331,Line1Incorrectsyntaxnear'-'.Msg319,Level15,State1,Server9cd172370331,Line1Incorrectsyntaxnearthekeyword'with'.Ifthisstatementisacommontableexpression,anxmlnamespacesclauseorachangetrackingcontextclause,thepreviousstatementmustbeterminatedwithasemicolon.```搞了很久才发现,数据库恢复数据库名需要用中括号包起来,关键是简单名称又不需要。```//没问题/opt/mssql-tools/bin/sqlcmd-Slocalhost-USA-P'password'-Q"RESTO...

    2021年12月10日 SQLServer MSSQL
  • docker删除容器文件没有权限

    `docker`删除容器文件提示没有权限:`Permissiondenied`,使用下面命令进入容器:```dockerexec-u0-it容器名称/bin/bash```

    2021年12月10日 docker
  • SpringCloudGateway导致Session失效

    使用Gateway集成`spring-boot-starter-oauth2-resource-server`会导致Session的Cookie被删除。##解决办法添加配置:```.requestCache().requestCache(NoOpServerRequestCache.getInstance())```

    2021年12月05日 SpringCloud Gateway Session
  • HttpURLConnection发送GET自动转为POST

    使用HttpURLConnection发送GET请求,如果带有请求体会自动转为POST请求:```privatesynchronizedOutputStreamgetOutputStream0()throwsIOException{...if(method.equals("GET")){method="POST";//Backwardcompatibility}...```

    2021年12月04日 HttpURLConnection
  • docker-compose启动没有服务

    使用docker-compose启动提示:```ERROR:Nosuchservice:rmqbroker```后来发现配置的服务名称和容器名称不一致,使用ps显示的是容器名称。```service-name:container_name:container-name```

    2021年11月30日 docker docker-compose
  • Nacos配置加载顺序

    ##bootstrap.yml```spring:application:name:demomain:allow-bean-definition-overriding:trueprofiles:active:devcloud:nacos:username:nacospassword:nacosdiscovery:namespace:${spring.profiles.active}server-addr:localhost:8848config:namespace:${spring.profiles.active}file-extension:ymlshared-dataids:a.ymlrefreshable-dataids:b.ymlext-config:-data-id:c.ymlrefresh:true```>通过namespace隔离环境,可以通过group隔离本地开发用户。##Nacos配置```demo.ymldemo-dev.ymla.ymlb.ymlc.ymldemo```##加载顺序```demo-dev.ymldemo.ymldemoc.ymlb.ymla.yml```>优先...

    2021年11月30日 Nacos
  • SpringBoot启动不能获取参数

    通过命令启动SpringBoot使用`-D`不能正确获取参数,使用`--`却可以,原来`-D`需要在`-jar`之前设置。```#不行java-jarrocketmq-console.jar-Drocketmq.config.namesrvAddr=192.168.1.100:9876#可以java-Drocketmq.config.namesrvAddr=192.168.1.100:9876-jarrocketmq-console.jar#可以java-jarrocketmq-console.jar--rocketmq.config.namesrvAddr=192.168.1.100:9876````-D`是`VMarguments`需要在`-jar`前面,可以通过`System.getProperty()`直接获取。`--`是`Programarguments`参数,由`main`函数`args`传入,需要自己解析。

    2021年11月29日 SpringBoot
  • Eclipse安装m2e-apt解决MapStruct编译问题

    新公司用MapStruct来处理对象转换,Eclipse需要安装m2e-apt插件才能编译成功。然后修改配置:`Maven->annotationprocessing`

    2021年11月29日 MapStruct m2e-apt
  • Spring Oauth2

    最近在看SpringOauth2的东西,开始看的非常迷糊,后来才有点点找到门路。先看下现在的SpringOauth2依赖:```spring-security-oauth2spring-cloud-starter-oauth2spring-security-oauth2-clientspring-security-oauth2-resource-serverspring-security-oauth2-authorization-serverspring-boot-starter-oauth2-clientspring-boot-starter-oauth2-resource-server```兄弟们是不是非常乱,`spring-security-oauth2`已经标注废弃。`spring-cloud-starter-oauth2`网上代码基本上都是通过这个实现的,基于`spring-security-oauth2`实现,所以废弃应该是迟早的事情。官方现在推荐使用的应该是`spring-security-oauth2`开头的这些,下面的`spring-boot-starter-oauth2`对应包含上面`sp...

    2021年11月29日 Spring Oauth2
  • SpringBoot、SpringCloud、SpringCloudAlibaba版本

    这三个东西就是一环套一环,版本一定要做到统一才能不出现各种奇奇怪怪的BUG。最底层肯定都是Spring的版本,当然都是依赖SpringBoot,所以SpringBoot版本统一就基本上没啥冲突了。[https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies](https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies)[https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies](https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies)由于都是后面依赖前面的,所以我们统一版本的时候需要倒着往前推。最新SpringCloudAlibaba是`2021.1`,然...

    2021年11月20日 SpringBoot SpringCloud SpringCloudAlibaba
  • 使用Prometheus和Grafana监控JVM

    我是在windows上面安装,比较简单:##下载[https://prometheus.io/download/](https://prometheus.io/download/)[https://grafana.com/grafana/download](https://grafana.com/grafana/download)##配置Prometheus```-job_name:"asc-gateway"scrape_interval:5smetrics_path:'/actuator/prometheus'static_configs:-targets:["localhost:8888"]```##配置SpringBoot####依赖```org.springframework.bootspring-boot-starter-actuatorio.micrometermicrometer-registry-prometheus```####端点配置```server:port:8888management:endpoints:web:exposure:include:-prometheus```##启动...

    2021年11月20日 Prometheus Grafana
  • SpringCloudAlibaba整合SpringCloudGateway问题

    其实我以前一直没有理解为什么需要网关,我觉得使用nginx就可以了,后来我发现很多服务后台的权限管理比较弱,例如flink、nacos这些,所以需要网关鉴权。不多说开始的时候用的版本:```2020.0.42.2.6.RELEASE```##问题一:负载均衡```Description:Parameter0ofmethodloadBalancerWebClientBuilderBeanPostProcessorinorg.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfigurationrequiredabeanoftype'org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction'thatcouldnotbefound.Action:Considerdefiningabeanoftype'org.springframework.cloud.cl...

    2021年11月20日 SpringCloudAlibaba SpringCloudGateway
  • Kafka

    Windows安装Kafka真是问题多多##AccessDeniedException```[2021-11-1817:15:09,038]ERRORErrorwhilewritingtocheckpointfileE:\develop\kafka_2.12-3.0.0\tmp\kafka-logs\log-start-offset-checkpoint(kafka.server.LogDirFailureChannel)java.nio.file.AccessDeniedException:E:\develop\kafka_2.12-3.0.0\tmp\kafka-logsatsun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)atsun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)atsun.nio.fs.WindowsException.rethrowAsIOException(WindowsException...

    2021年11月18日 Kafka
  • 分布式锁和分布式定时任务

    以前微服务里面使用定时任务,都是只启动一个定时任务,但是这个服务挂了就GG。我的解决思路就是用分布式锁来实现,每次只有获得锁的服务才可以执行定时任务。分布式锁可以使用redis、zookeeper或者数据库表。##redis为了防止服务挂掉,需要设置一个锁的过期时间,然后每次获得锁进行续期。##zookeeperzookeeper可以设置临时节点服务挂了会自动释放。##数据库表和redis类似>全是理论没有实践##实践项目有兴趣的同学可以看下:[https://gitee.com/acgist/distributed](https://gitee.com/acgist/distributed)

    2021年11月13日 分布式 定时任务 分布式锁
  • Sentinel限流熔断降级

    我们需要区分这几个词:限流、熔断、降级限流:某个服务资源的QPS熔断:服务出现问题被禁用(超时、异常、调用时间过长)降级:限流或者熔断后服务返回一个临时结果(活动火爆稍后重试)限流和熔断都可以出现降级主要区别`fallback`和`blockHandler`参数,如果没有配置`blockHandler`,都会进入到`fallback`,因为限流异常也属于异常。还有就是两个方法的异常类型是不能修改的,如果需要全局处理可以定义异常处理`ControllerAdvice`。感觉对于微服务内部限流没啥太大必要,主要还是控制外部请求就可以了。所以sentinel的dubbo适配和dashboard也没啥用,感觉只会增加系统负担。当然个人理解,没有大型系统的经验,可能有点浅薄。有时候人总是想把握住太多,导致失去的更多。```@PostConstructpublicvoidinit(){Listrules=newArrayList<>();FlowRulerule=newFlowRule();rule.setResource("name");rule.setGrade(RuleConstant.FLOW_GRA...

    2021年11月12日 Sentinel 限流 熔断 降级
  • Flink

    下载地址:[https://flink.apache.org/downloads.html](https://flink.apache.org/downloads.html)文档地址:[https://ci.apache.org/projects/flink/flink-docs-release-1.10/zh/](https://ci.apache.org/projects/flink/flink-docs-release-1.10/zh/)>最新文档可能没有汉化生产环境使用:FlinkonYarn,不过学习直接使用单机就可以了。下载一个版本`ApacheFlink1.14.0forScala2.12`,解压然后使用命令`./start-cluster.sh`即可启动。##简单理解Flink编程流程就是先把数据进行分析处理映射成一张虚拟表,然后再对这个表进行聚合操作。##Windows启动提示```错误:找不到或无法加载主类org.apache.flink.runtime.taskexecutor.TaskManagerRunner错误:找不到或无法加载主类org.apache.flink.runti...

    2021年11月11日 Flink
  • Spring重写配置

    SpringBoot自动配置很好用,但是有时候会出现一些情况就是自动配置里面有些配置并不能通过配置文件修改,这时候就可以使用`@Bean`和`@Configuration`或者`@Configuration`和`@PostConstruct`轻松实现。例如`activiti`的字体配置和`IdGenerator`配置可以使用下面方法:```importorg.activiti.engine.ProcessEngineConfiguration;importorg.activiti.engine.impl.cfg.IdGenerator;importorg.activiti.spring.SpringProcessEngineConfiguration;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;@ConfigurationpublicclassConfig{//@Autowired//privateProcessEngineConfigu...

    2021年11月10日 Spring @Bean @Configuration
  • activiti工作流

    DEMO地址:[https://gitee.com/acgist/demo/tree/master/activiti](https://gitee.com/acgist/demo/tree/master/activiti)##添加依赖```org.activitiactiviti-spring-boot-starter-basic6.0.0```出现异常:```Causedby:java.lang.ClassNotFoundException:org.springframework.boot.autoconfigure.security.SecurityAutoConfigurationatjava.net.URLClassLoader.findClass(URLClassLoader.java:382)~[na:1.8.0_191]atjava.lang.ClassLoader.loadClass(ClassLoader.java:424)~[na:1.8.0_191]atsun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)~[na:1....

    2021年11月09日 activiti 工作流
  • sharding-jdbc学习

    项目地址:[https://gitee.com/acgist/demo/tree/master/sharding](https://gitee.com/acgist/demo/tree/master/sharding)官方配置:[https://shardingsphere.apache.org/document/legacy/4.x/document/cn/manual/sharding-jdbc/configuration/config-spring-boot](https://shardingsphere.apache.org/document/legacy/4.x/document/cn/manual/sharding-jdbc/configuration/config-spring-boot)##主要功能*读写分离*分库分表`dsmaster,dsslave`-`tb_user`:读写分离`ds0master,ds0slave,ds1master,ds1slave`-`tb_order`:分库分表、读写分离##配置```spring:shardingsphere:datasource:names:d...

    2021年11月09日 sharding-jdbc 主从 读写分离 分库分表
  • 算法

    其实大部分时候都可以使用别人写好的数据结构和算法,但是还是需要多看看,主要是可以拓宽我们的思维的。##共识算法RaftPaxos

    2021年11月06日 算法
1...567891011...31

关于 ACGIST

Copyright © 2013-2025 ACGIST.COM. All Rights Reserved.