jooq实践

用法

  sql语句

SELECT AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, COUNT(*)FROM AUTHORJOIN BOOK ON AUTHOR.ID = BOOK.AUTHOR_IDWHERE BOOK.LANGUAGE = 'DE'AND BOOK.PUBLISHED > DATE '2008-01-01'
GROUP BY AUTHOR.FIRST_NAME, AUTHOR.LAST_NAMEHAVING COUNT(*) > 5
ORDER BY AUTHOR.LAST_NAME ASC NULLS FIRSTLIMIT 2OFFSET 1

  java代码

dsl.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count()).from(AUTHOR).join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID)).where(BOOK.LANGUAGE.eq("DE")).and(BOOK.PUBLISHED.gt(date("2008-01-01"))).groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME).having(count().gt(5)).orderBy(AUTHOR.LAST_NAME.asc().nullsFirst()).limit(2).offset(1)

 

示例代码

增:
public void addMerchantUrgentIsochrone(ITbMerchantUrgentIsochrone merchantUrgentIsochrone) {TbMerchantUrgentIsochroneRecord record = dsl.newRecord(TB_MERCHANT_URGENT_ISOCHRONE, merchantUrgentIsochrone);record.store();merchantUrgentIsochrone.setId(record.getId());
}
删:
public int deleteRecords() {return dsl.delete(TB_MERCHANT_URGENT_ISOCHRONE).where(TB_MERCHANT_URGENT_ISOCHRONE.CREATED_AT.ge(Timestamp.valueOf(LocalDateTime.now().minusDays(1)))).execute();
}
改:
public int update(ITbUserArea userArea) {return dsl.update(TB_USER_AREA).set(TB_USER_AREA.GEOHASH, userArea.getGeohash()).set(TB_USER_AREA.AREA, userArea.getArea()).set(TB_USER_AREA.CITY_ID, userArea.getCityId()).set(TB_USER_AREA.ORDER_COUNT, userArea.getOrderCount()).where(TB_USER_AREA.ID.eq(userArea.getId())).execute();
}
查:
public List<ITbUserArea> getAreas(String preHash) {return dsl.selectFrom(TB_USER_AREA).where(TB_USER_AREA.GEOHASH.like(preHash+"%")).fetchInto(TbUserArea.class);
}

jooq 可以执行sql语句

Result<Record> fetch(String var1) throws DataAccessException;
int execute(String var1) throws DataAccessException;

配置篇

  maven配置

Maven依赖:(版本号可配)
<dependency><groupId>org.jooq</groupId><artifactId>jooq</artifactId><version>3.9.5</version>
</dependency>
<dependency><groupId>org.jooq</groupId><artifactId>jooq-meta</artifactId><version>3.9.5</version>
</dependency>
<dependency><groupId>org.jooq</groupId><artifactId>jooq-codegen</artifactId><version>3.9.5</version>
</dependency>工具生成映射配置:
建立 xxx.xml(名字任意)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration><jdbc><driver>...</driver><url>...</url><user>...</user><password>...</password></jdbc><generator><!-- 指定代码风格- org.jooq.util.ScalaGenerator- org.jooq.util.JavaGenerator--><name>org.jooq.util.JavaGenerator</name><database><!-- 数据库类型 --><name>org.jooq.util.postgres.PostgresDatabase</name><!-- <name>org.jooq.util.mysql.MySQLDatabase</name> --><excludes><!-- 对tb_table1,tb_table2,tb_table3 表不生成代码-->tb_table1|tb_table2|tb_table3</excludes><includeExcludeColumns>true</includeExcludeColumns><inputSchema>public</inputSchema><!-- jooq转换对象类型,如用enum代替int目标转换类型应实现org.jooq.Converter或org.jooq.Binding接口相应的配置标签为<customType>,<forcedType>参考地址: https://www.jooq.org/doc/3.9/manual/code-generation/custom-data-types/https://www.jooq.org/doc/3.9/manual/code-generation/custom-data-type-bindings/--><customTypes><customType><name>EffectiveStatus</name><type>xxx.isochrone.constant.EffectiveStatus</type><converter>xxx.geo.jooq.converter.EffectiveStatusConverter</converter></customType></customTypes><forcedTypes><!-- 使用converter --><forcedType><name>EffectiveStatus</name><expressions>.*\.tb_isochrone_audit_info\.effective_status</expressions><types>.*</types></forcedType><!-- 使用binding --><forcedType><userType>xxx.isochrone.pojos.GeographyPolygon</userType><binding>xxx.geo.jooq.binding.PGgeometryPolygonBinding</binding><expression>.*\.tb_isochrone.range|.*\.tb_merchant_area_isochrone.range</expression><types>.*</types></forcedType></forcedTypes></database><generate><deprecated>false</deprecated><daos>true</daos><interfaces>true</interfaces></generate><target><!-- 生成的包名,生成的类在此包下 --><packageName>xxx.isochrone.jooq</packageName><!-- 输出的目录 --><directory>src/main/java</directory></target></generator>
</configuration>相应pom.xml里添加对应的配置信息
<profiles><profile><id>db-gen</id><build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>1.4.0</version><executions><execution><goals><goal>java</goal></goals></execution></executions><configuration><includeProjectDependencies>false</includeProjectDependencies><includePluginDependencies>true</includePluginDependencies><mainClass>org.jooq.util.GenerationTool</mainClass><cleanupDaemonThreads>false</cleanupDaemonThreads><arguments><!-- 匹配工具生成映射配置文件 --><argument>xxx.xml</argument></arguments></configuration><dependencies><dependency><groupId>org.jooq</groupId><artifactId>jooq</artifactId><version>3.9.5</version></dependency><dependency><groupId>org.jooq</groupId><artifactId>jooq-codegen</artifactId><version>3.9.5</version></dependency><dependency><groupId>org.jooq</groupId><artifactId>jooq-meta</artifactId><version>3.9.5</version></dependency><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>9.4.1208.jre7</version></dependency></dependencies></plugin></plugins></build></profile>
</profiles>

执行代码自动生成命令
mvn -P db-gen exec:java

  gradle配置

application.yml

spring:
  jooq:
    #请勿动,当使用了ejdbc的配置后,Spring Boot无法识别正确的Dialect
    sqlDialect: Mysql


jooq模块下的gradle文件
apply plugin: 'io.spring.dependency-management' dependencyManagement {resolutionStrategy {cacheChangingModulesFor 0, 'seconds'}imports {mavenBom 'io.spring.platform:platform-bom:Brussels-SR6'mavenBom 'org.jooq:jooq:3.10.1'}dependencies {dependency 'org.springframework.statemachine:spring-statemachine-core:1.2.6.RELEASE'} }apply plugin: 'nu.studer.jooq'emodule {dependency 'tms-jooq-model' } dependencies {compile 'org.jooq:jooq'jooqRuntime 'mysql:mysql-connector-java' }// Jooq Gradle Plugin 参考文档 https://github.com/etiennestuder/gradle-jooq-plugin jooq {version = '3.10.1'tms(sourceSets.main) {jdbc {driver = 'com.mysql.jdbc.Driver'url = 'jdbc:mysql://localhost:3306/test'user = 'xxx'password = 'xxx'}generator {name = 'org.jooq.util.DefaultGenerator'database {name = 'org.jooq.util.mysql.MySQLDatabase'inputSchema = 'scm_tms'outputSchemaToDefault = trueincludeExcludeColumns = true//重构,相关字段迁移到tb_docker_deployment_log中excludes = ".*_bak|.*\\.drc_check_time|.*\\.is_delete|.*\\.updated_at"forcedTypes {forcedType {userType = "xxx.common.model.model.GeoPoint"converter = "xxx.jooq.model.converter.GeoPointConverter"expression = ".*_lnglat"types = ".*"}forcedType {userType = "xxx.base.api.model.UsedType"converter = "xxx.jooq.model.converter.VehicleIsUsedTypeConverter"/*A Java regular expression matching fully-qualified columns. Use the pipe to separate several expressions. ->database.table.column*/expression = ".*\\.base_vehicle\\.is_used"/*Add a Java regular expression matching data types to be forced to have this type*/types = ".*"}}}generate {relations = truedeprecated = falserecords = trueinterfaces = truepojos = truedaos = falsefluentSetters = true}target {packageName = project.groupPrefix + "." + project.groupName + ".db.model"directory = 'src/main/java'}}} }//不自动执行Jooq的代码生成和清除任务 //数据库更改后,手动进入 jooq模块 //执行 gradle cleanGenerateTmsJooqSchemaSource generateTmsJooqSchemaSource //生成数据库对象在tms-db-model下 project.tasks.getByName('compileJava').dependsOn -= 'generateTmsJooqSchemaSource' project.tasks.getByName('clean').dependsOn -= 'cleanGenerateTmsJooqSchemaSource'

 

jooq Converter示例

import xxx.GeoPoint;
import org.jooq.Converter;public class GeoPointConverter implements Converter<String, GeoPoint> {@Overridepublic GeoPoint from(String databaseObject) {return new GeoPoint(databaseObject);}@Overridepublic String to(GeoPoint point) {return point==null?"":point.gdFormat();}@Overridepublic Class<String> fromType() {return String.class;}@Overridepublic Class<GeoPoint> toType() {return GeoPoint.class;}
}public class GeoPoint {/*** 经度值*/private Double longitude;/*** 纬度值*/private Double latitude;public GeoPoint() {}public GeoPoint(String location) {if (!StringUtils.isEmpty(location)) {String[] lnglat = location.split(",");this.longitude = Double.valueOf(lnglat[0]);this.latitude = Double.valueOf(lnglat[1]);}}public Double getLongitude() {return longitude;}public void setLongitude(Double longitude) {this.longitude = longitude;}public Double getLatitude() {return latitude;}public void setLatitude(Double latitude) {this.latitude = latitude;}public String gdFormat() {if (longitude == null || latitude == null) {return "";}return longitude + "," + latitude;}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;GeoPoint geoPoint = (GeoPoint) o;if (longitude != null ? !longitude.equals(geoPoint.longitude) : geoPoint.longitude != null) return false;return latitude != null ? latitude.equals(geoPoint.latitude) : geoPoint.latitude == null;}@Overridepublic int hashCode() {int result = longitude != null ? longitude.hashCode() : 0;result = 31 * result + (latitude != null ? latitude.hashCode() : 0);return result;}@Overridepublic String toString() {return "GeoPoint{" +"longitude=" + longitude +", latitude=" + latitude +'}';}}

 

import xxx.scm.tms.common.model.model.WarehouseType;
import org.jooq.Converter;/*** WarehouseTypeConverter*/
public class WarehouseTypeConverter implements Converter<Byte, WarehouseType> {@Overridepublic WarehouseType from(Byte databaseObject) {return WarehouseType.getTypeByCode(databaseObject);}@Overridepublic Byte to(WarehouseType warehouseType) {return warehouseType.getCode();}@Overridepublic Class<Byte> fromType() {return Byte.class;}@Overridepublic Class<WarehouseType> toType() {return WarehouseType.class;}
}import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;public enum WarehouseType {NORMAL_TEMPERATURE((byte)1, "常温"),COLD_STORAGE((byte)2, "冷藏"),FREEZING((byte)3, "冷冻");private byte code;private String label;WarehouseType(byte code, String label) {this.code = code;this.label = label;}public byte getCode() {return code;}public String getLabel() {return label;}private static Map<Byte, WarehouseType> map = new HashMap<>();static {EnumSet.allOf(WarehouseType.class).forEach(e -> map.put(e.getCode(), e));}public static WarehouseType getTypeByCode(Byte code) {return map.get(code);}
}

 

高级用法代码示例

public List<BaseWarehouse> searchWarehouses(WarehouseCondition warehouseCondition) {SelectConditionStep<?> step = dsl.selectFrom(Tables.BASE_WAREHOUSE).where(DSL.trueCondition());StringBuilder likeValue = new StringBuilder();if (!Objects.isNull(warehouseCondition.getWarehouseId())) {step.and(Tables.BASE_WAREHOUSE.WAREHOUSE_ID.eq(warehouseCondition.getWarehouseId()));}if (StringUtils.isNotBlank(warehouseCondition.getWarehouseName())) {likeValue.setLength(0);likeValue.append("%").append(warehouseCondition.getWarehouseName()).append("%");step.and(Tables.BASE_WAREHOUSE.WAREHOUSE_NAME.likeIgnoreCase(likeValue.toString()));}if (StringUtils.isNotBlank(warehouseCondition.getCompany())) {likeValue.setLength(0);likeValue.append("%").append(warehouseCondition.getCompany()).append("%");step.and(Tables.BASE_WAREHOUSE.COMPANY.likeIgnoreCase(likeValue.toString()));}if (StringUtils.isNotBlank(warehouseCondition.getProvinceName())) {step.and(Tables.BASE_WAREHOUSE.PROVINCE_NAME.eq(warehouseCondition.getProvinceName()));}if (!Objects.isNull(warehouseCondition.getProvinceId())) {step.and(Tables.BASE_WAREHOUSE.PROVINCE_ID.eq(warehouseCondition.getProvinceId()));}if (StringUtils.isNotBlank(warehouseCondition.getCityName())) {step.and(Tables.BASE_WAREHOUSE.CITY_NAME.eq(warehouseCondition.getCityName()));}if (!Objects.isNull(warehouseCondition.getCityId())) {step.and(Tables.BASE_WAREHOUSE.CITY_ID.eq(warehouseCondition.getCityId()));}if (StringUtils.isNotBlank(warehouseCondition.getDistrictName())) {step.and(Tables.BASE_WAREHOUSE.DISTRICT_NAME.eq(warehouseCondition.getDistrictName()));}if (!Objects.isNull(warehouseCondition.getDistrictId())) {step.and(Tables.BASE_WAREHOUSE.DISTRICT_ID.eq(warehouseCondition.getDistrictId()));}if (StringUtils.isNotBlank(warehouseCondition.getAddress())) {likeValue.setLength(0);likeValue.append("%").append(warehouseCondition.getAddress()).append("%");step.and(Tables.BASE_WAREHOUSE.ADDRESS.like(likeValue.toString()));}if (!Objects.isNull(warehouseCondition.getWarehouseLnglat())) {step.and(Tables.BASE_WAREHOUSE.WAREHOUSE_LNGLAT.eq(warehouseCondition.getWarehouseLnglat()));}if (StringUtils.isNotBlank(warehouseCondition.getContactName())) {step.and(Tables.BASE_WAREHOUSE.CONTACT_NAME.eq(warehouseCondition.getContactName()));}if (StringUtils.isNotBlank(warehouseCondition.getContactPhone())) {step.and(Tables.BASE_WAREHOUSE.CONTACT_PHONE.eq(warehouseCondition.getContactPhone()));}return step.fetchInto(BaseWarehouse.class);
}private Collection<SelectField<?>> getListField() {Collection<SelectField<?>> fields = new ArrayList<>();fields.add(SHIPMENT.SHIPMENT_ID);fields.add(SHIPMENT.OUTBOUND_ID);fields.add(SHIPMENT.BIZ_TYPE);fields.add(SHIPMENT.BIZ_SUBTYPE);fields.add(SHIPMENT.PICKUP_NAME);fields.add(SHIPMENT.PICKUP_CONTACT_NAME);fields.add(SHIPMENT.PICKUP_CONTACT_PHONE);fields.add(SHIPMENT.PICKUP_PROVINCE_NAME);fields.add(SHIPMENT.PICKUP_CITY_NAME);fields.add(SHIPMENT.PICKUP_DISTRICT_NAME);fields.add(SHIPMENT.PICKUP_ADDRESS);fields.add(SHIPMENT.DESTINATION_NAME);fields.add(SHIPMENT.DESTINATION_CONTACT_NAME);fields.add(SHIPMENT.DESTINATION_CONTACT_PHONE);fields.add(SHIPMENT.DESTINATION_PROVINCE_NAME);fields.add(SHIPMENT.DESTINATION_CITY_NAME);fields.add(SHIPMENT.DESTINATION_DISTRICT_NAME);fields.add(SHIPMENT.DESTINATION_ADDRESS);fields.add(SHIPMENT.DESTINATION_REMARK);fields.add(SHIPMENT.ORDER_ID);fields.add(SHIPMENT.ORDER_CREATED_AT);fields.add(SHIPMENT.STATUS);fields.add(DSL.ifnull(SHIPMENT_SKU.SHIPMENT_ID.count(), 0).as("COUNT"));fields.add(DSL.ifnull(SHIPMENT_SKU.SKU_COUNT.sum(), BigDecimal.ZERO).as("SKU_COUNT"));fields.add(DSL.ifnull(SHIPMENT_SKU.OUTBOUND_COUNT.sum(), BigDecimal.ZERO).as("OUTBOUND_COUNT"));fields.add(DSL.ifnull(SHIPMENT_SKU.SIGN_COUNT.sum(), BigDecimal.ZERO).as("SIGN_COUNT"));fields.add(SHIPMENT.PICKUP_LNGLAT);fields.add(SHIPMENT.DESTINATION_LNGLAT);fields.add(SHIPMENT.EXPECT_ARRIVE_BEGIN_AT);fields.add(SHIPMENT.EXPECT_ARRIVE_END_AT);fields.add(SHIPMENT.BIZ_JSON);fields.add(SHIPMENT.WAREHOUSE_ID);fields.add(SHIPMENT.DRIVER_REMARK);//detail使用字段
    fields.add(SHIPMENT.DRIVER_ID);fields.add(SHIPMENT.CUSTOMER_SERVICE);fields.add(SHIPMENT.CARRIER_ID);fields.add(SHIPMENT.CARRIER_NAME);fields.add(SHIPMENT.ROUTE_ID);return fields;
}
Result<Record> records = dsl.select(getListField()).from(SHIPMENT).leftJoin(SHIPMENT_SKU).on(SHIPMENT.SHIPMENT_ID.eq(SHIPMENT_SKU.SHIPMENT_ID)).where(getListConditions(query)).groupBy(SHIPMENT.SHIPMENT_ID).orderBy(SHIPMENT.CREATED_AT.desc()).offset(query.getOffset()).limit(query.getLimit()).fetch();

 

DSLContext executeUpdate

   dsl.executeUpdate(dsl.newRecord(BASE_WAREHOUSE, baseWarehouse)), 如果vo类中的主键为null的时候

  

  要指定 condition

  

 

乐观锁实现

  https://www.jooq.org/doc/3.10/manual-single-page/#optimistic-locking

  https://www.jooq.org/doc/3.10/manual-single-page/#codegen-config-record-version-timestamp-fields

转载于:https://www.cnblogs.com/hujunzheng/p/8342999.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/531235.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

git根据用户过滤提交记录

使用SourceTree 使用gitk 转载于:https://www.cnblogs.com/hujunzheng/p/8398203.html

cglib动态代理导致注解丢失问题及如何修改注解允许被继承

现象 SOAService这个bean先后经过两个BeanPostProcessor&#xff0c;会发现代理之后注解就丢失了。 开启了cglib代理 SpringBootApplication EnableAspectJAutoProxy(proxyTargetClass true) public class Application {public static void main(String[] args) {SpringApplic…

spring AbstractBeanDefinition创建bean类型是动态代理类的方式

1.接口 Class<?> resourceClass 2.获取builder BeanDefinitionBuilder builder BeanDefinitionBuilder.genericBeanDefinition(resourceClass); 3.获取接口对应的动态代理class Class<?> targetProxyClass Proxy.getProxyClass(XXX.class.getClassLoader(), ne…

微信小程序:一起玩连线,一个算法来搞定

微信小程序&#xff1a;一起玩连线 游戏玩法 将相同颜色的结点连接在一起&#xff0c;连线之间不能交叉。 算法思想 转换为多个源点到达对应终点的路径问题&#xff0c;且路径之间不相交。按照dfs方式寻找两个结点路径&#xff0c;一条路径探索完之后&#xff0c;标记地图并记录…

IntelliJ IDEA关于logger的live template配置

1.安装 log support2插件 2.配置log support2 由于项目中的日志框架是公司自己封装的&#xff0c;所以还需要自己手动改一下 log support2插件生成的live template 当然也可以修改 Log support global的配置 包括 Logger Field、Logger class、Logger Factory class都可以修改。…

springboot项目接入配置中心,实现@ConfigurationProperties的bean属性刷新方案

前言 配置中心&#xff0c;通过keyvalue的形式存储环境变量。配置中心的属性做了修改&#xff0c;项目中可以通过配置中心的依赖&#xff08;sdk&#xff09;立即感知到。需要做的就是如何在属性发生变化时&#xff0c;改变带有ConfigurationProperties的bean的相关属性。 配置…

简单封装kafka相关的api

一、针对于kafka版本 <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-clients</artifactId><version>0.8.2.2</version></dependency><dependency><groupId>org.apache.kafka</groupId>…

springmvc controller动态设置content-type

springmvc RequestMappingHandlerAdapter#invokeHandlerMethod 通过ServletInvocableHandlerMethod#invokeAndHandle调用目标方法&#xff0c;并处理返回值。 如果return value &#xff01; null&#xff0c;则通过returnvalueHandlers处理&#xff0c;内部会调用MessageConv…

springboot2.0 redis EnableCaching的配置和使用

一、前言 关于EnableCaching最简单使用&#xff0c;个人感觉只需提供一个CacheManager的一个实例就好了。springboot为我们提供了cache相关的自动配置。引入cache模块&#xff0c;如下。 二、maven依赖 <dependency><groupId>org.springframework.boot</groupId…

依赖配置中心实现注有@ConfigurationProperties的bean相关属性刷新

配置中心是什么 配置中心&#xff0c;通过keyvalue的形式存储环境变量。配置中心的属性做了修改&#xff0c;项目中可以通过配置中心的依赖&#xff08;sdk&#xff09;立即感知到。需要做的就是如何在属性发生变化时&#xff0c;改变带有ConfigurationProperties的bean的相关属…

java接口签名(Signature)实现方案

预祝大家国庆节快乐&#xff0c;赶快迎接美丽而快乐的假期吧&#xff01;&#xff01;&#xff01; 前言 在为第三方系统提供接口的时候&#xff0c;肯定要考虑接口数据的安全问题&#xff0c;比如数据是否被篡改&#xff0c;数据是否已经过时&#xff0c;数据是否可以重复提交…

Git rebase命令实战

一、前言 一句话&#xff0c;git rebase 可以帮助项目中的提交历史干净整洁&#xff01;&#xff01;&#xff01; 二、避免合并出现分叉现象 git merge操作 1、新建一个 develop 分支 2、在develop分支上新建两个文件 3、然后分别执行 add、commit、push 4、接着切换到master分…

windows系统nexus3安装和配置

一、前言 为什么要在本地开发机器上安装nexus&#xff1f;首先声明公司内部是有自己的nexus仓库&#xff0c;但是对上传jar包做了限制&#xff0c;不能畅快的上传自己测试包依赖。于是就自己在本地搭建了一个nexus私服&#xff0c;即可以使用公司nexus私服仓库中的依赖&#xf…

Springmvc借助SimpleUrlHandlerMapping实现接口开关功能

一、接口开关功能 1、可配置化&#xff0c;依赖配置中心 2、接口访问权限可控 3、springmvc不会扫描到&#xff0c;即不会直接的将接口暴露出去 二、接口开关使用场景 和业务没什么关系&#xff0c;主要方便查询系统中的一些状态信息。比如系统的配置信息&#xff0c;中间件的状…

log4j平稳升级到log4j2

一、前言 公司中的项目虽然已经用了很多的新技术了&#xff0c;但是日志的底层框架还是log4j&#xff0c;个人还是不喜欢用这个的。最近项目再生产环境上由于log4j引起了一场血案&#xff0c;于是决定升级到log4j2。 二、现象 虽然生产环境有多个结点分散高并发带来的压力&…

Springboot集成ES启动报错

报错内容 None of the configured nodes are available elasticsearch.yml配置 cluster.name: ftest node.name: node-72 node.master: true node.data: true network.host: 112.122.245.212 http.port: 39200 transport.tcp.port: 39300 discovery.zen.ping.unicast.hosts: [&…

kafka-manager配置和使用

kafka-manager配置 最主要配置就是用于kafka管理器状态的zookeeper主机。这可以在conf目录中的application.conf文件中找到。 kafka-manager.zkhosts"my.zookeeper.host.com:2181" 当然也可以声明为zookeeper集群。 kafka-manager.zkhosts"my.zookeeper.host.co…

kafka告警简单方案

一、前言 为什么要设计kafka告警方案&#xff1f;现成的监控项目百度一下一大堆&#xff0c;KafkaOffsetMonitor、KafkaManager、 Burrow等&#xff0c;具体参考&#xff1a;kafka的消息挤压监控。由于本小组的项目使用的kafka集群并没有被公司的kafka-manager管理&#xff0c;…

RedisCacheManager设置Value序列化器技巧

CacheManager基本配置 请参考博文&#xff1a;springboot2.0 redis EnableCaching的配置和使用 RedisCacheManager构造函数 /*** Construct a {link RedisCacheManager}.* * param redisOperations*/ SuppressWarnings("rawtypes") public RedisCacheManager(RedisOp…

HashMap 源码阅读

前言 之前读过一些类的源码&#xff0c;近来发现都忘了&#xff0c;再读一遍整理记录一下。这次读的是 JDK 11 的代码&#xff0c;贴上来的源码会去掉大部分的注释, 也会加上一些自己的理解。 Map 接口 这里提一下 Map 接口与1.8相比 Map接口又新增了几个方法&#xff1a;   …