Android MQTT连接阿里云使用Json解析数据

news2024/10/7 6:29:34

Android Studio 连接阿里云订阅主题然后使用JSON解析数据非常好用

  • 导入MQTT的JAR包
    • 1、在项目中添加依赖然后使用Studio 去下载库
    • 2、直接下载JAR包,然后作为库进行导入
  • 环境验证:
  • 给程序进行联网权限
  • XML布局文件
    • 效果如下:
  • MainActitive.java 主要代码如下:
  • End

导入MQTT的JAR包

这里有两种方法:

1、在项目中添加依赖然后使用Studio 去下载库

2、直接下载JAR包,然后作为库进行导入

这里先介绍第一种方法:
切换到Android 目录:
在这里插入图片描述按照如下图,添加依赖即可:
在这里插入图片描述

  implementation("org.eclipse.paho:mqtt-client:3-1.2.0")

在这里插入图片描述
第二种方法:
打开Android Studio 然后切换到Android 目录找到Lib文件夹,将MQTT的JAR包复制进去即可。
在这里插入图片描述
然后点击project目录然后将MQTT JAR包导进去
在这里插入图片描述
添加完成之后作为库导入工程中
在这里插入图片描述

环境验证:

在MainActivity 任取一个地方输入MQTT 看是否有提示弹窗。
在这里插入图片描述
到这里以及成功一半了。接下来就是设置一些权限问题

给程序进行联网权限

切换到按的Android 目录
在这里插入图片描述
找到如下的目录:
在这里插入图片描述
添加如代码:

 <uses-permission android:name="android.permission.INTERNET" />
    <!--允许程序获取网络状态-->
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

XML布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:background="#51CCDC"
        android:orientation="vertical"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:background="#673AB7"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="match_parent"
                android:text="桂航果蔬种植基地"
                android:textSize="25sp"
                android:textColor="#060A0C"
                android:layout_height="match_parent">
            </TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="200dp"
            android:layout_gravity="center"
            android:layout_marginTop="20dp">
            <androidx.cardview.widget.CardView
                android:layout_width="wrap_content"
                android:layout_height="200dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                app:cardCornerRadius="20dp">
                <ImageView
                    android:id="@+id/m_img2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/bg3"
                    />
            </androidx.cardview.widget.CardView>
        </LinearLayout>

        <LinearLayout

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="#51CCDC"
            android:orientation="vertical">
            <LinearLayout
                android:layout_marginBottom="3dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_width="match_parent"
                android:background="@drawable/shape_corner"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_marginTop="5dp"
                android:padding="30dp">
                <!--左文字-->
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="学号:2020070230226"
                    android:textColor="@color/black"
                    android:textSize="16sp">
                </TextView>
                <!--左文字-->
                <TextView
                    android:id="@+id/m_mqtt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text= "姓名:xiao!"
                    android:textColor="@color/black"
                    android:textSize="16sp">
                </TextView>
            </LinearLayout>
        </LinearLayout>
        <!-- vertical 竖直排列 -->
        <!-- horizontal 竖直排列 -->
        <!-- 数据解析界面 -->
        <LinearLayout
            android:layout_marginTop="10dp"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FFFF">
            <!-- 包裹其他界面-->
            <LinearLayout
                android:layout_margin="5px"
                android:padding="3dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:gravity="center"
                    android:layout_weight="1"
                    android:orientation="horizontal"
                    android:layout_height="match_parent">
                    <!--气温-->
                    <LinearLayout
                        android:layout_width="160dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:background="@drawable/shape_corner"
                        android:layout_height="105dp">
                        <ImageView
                            android:id="@+id/test"
                            android:layout_width="80dp"
                            android:layout_height="80dp"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/air_temp"
                            android:layout_marginRight="15dp">
                        </ImageView>
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:orientation="vertical"
                            android:layout_height="wrap_content">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:text="温度"
                                android:textSize="25sp">
                            </TextView>
                            <!-- 数值 -->
                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/air_temp"
                                    android:layout_width="wrap_content"
                                    android:text=" 0 "
                                    android:textSize="25sp"
                                    android:layout_height="wrap_content">
                                </TextView>
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                    <!--The End -->
                    <!-- 湿度-->
                    <LinearLayout
                        android:layout_marginLeft="25dp"
                        android:layout_width="160dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:background="@drawable/shape_corner"
                        android:layout_height="105dp">
                        <ImageView
                            android:layout_width="80dp"
                            android:layout_height="80dp"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/air_humi"
                            android:layout_marginRight="15dp">
                        </ImageView>
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:orientation="vertical"
                            android:layout_height="wrap_content">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:text="湿度"
                                android:textSize="20sp">
                            </TextView>
                            <!-- 数值 -->
                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/air_humi"
                                    android:layout_width="wrap_content"
                                    android:text=" 0 "
                                    android:textSize="25sp"
                                    android:layout_height="wrap_content">
                                </TextView>
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>
                <!--The End -->

            </LinearLayout>
            <!-- 2 -->
            <LinearLayout
                android:layout_width="match_parent"
                android:background="#FFFF"
                android:layout_margin="5px"
                android:padding="3dp"
                android:layout_height="wrap_content">
                <!-- Layout1-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:gravity="center"
                    android:layout_height="match_parent">
                    <!--气温-->
                    <!--Left1 -->
                    <LinearLayout
                        android:layout_width="160dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:background="@drawable/shape_corner"
                        android:layout_height="105dp">
                        <ImageView
                            android:layout_width="80dp"
                            android:layout_height="80dp"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/soil_humi"
                            android:layout_marginRight="15dp">
                        </ImageView>
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:orientation="vertical"
                            android:layout_height="wrap_content">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:text="土壤湿度"
                                android:textSize="20sp">
                            </TextView>
                            <!-- 数值 -->
                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/sloi_humi"
                                    android:layout_width="wrap_content"
                                    android:text=" 0 "
                                    android:textSize="25sp"
                                    android:layout_height="wrap_content">
                                </TextView>
                            </LinearLayout>

                        </LinearLayout>
                    </LinearLayout>
                    <!--The End -->

                    <!-- 湿度-->
                    <LinearLayout
                        android:layout_width="160dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:layout_marginLeft="25dp"
                        android:background="@drawable/shape_corner"
                        android:layout_height="105dp">
                        <ImageView
                            android:layout_width="80dp"
                            android:layout_height="80dp"
                            android:layout_marginTop="10dp"
                            android:src="@drawable/n2"
                            android:layout_marginRight="15dp">
                        </ImageView>
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:orientation="vertical"
                            android:layout_height="wrap_content">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:text="土壤含氮"
                                android:textSize="20sp">
                            </TextView>
                            <!-- 数值 -->
                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/soli_n"
                                    android:layout_width="wrap_content"
                                    android:text=" 0 "
                                    android:textSize="25sp"
                                    android:layout_height="wrap_content">
                                </TextView>
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
            <!-- The End -->
            <!-- 3 -->
            <LinearLayout
                android:layout_margin="5px"
                android:padding="3dp"
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:gravity="center"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:layout_width="160dp"
                    android:background="@drawable/shape_corner"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:layout_height="105dp">
                    <ImageView
                        android:layout_weight="1"
                        android:layout_width="80dp"
                        android:layout_height="80dp"
                        android:layout_marginTop="10dp"
                        android:src="@drawable/p2"
                        android:layout_marginRight="15dp">
                    </ImageView>
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:orientation="vertical"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_marginTop="5dp"
                            android:layout_marginRight="5dp"
                            android:layout_width="wrap_content"
                            android:text="土壤含磷"
                            android:textSize="20sp"
                            android:layout_height="wrap_content">
                        </TextView>
                        <TextView
                            android:id="@+id/soil_p"
                            android:layout_marginTop="5dp"
                            android:layout_width="wrap_content"
                            android:text=" 0 "
                            android:textSize="25sp"
                            android:layout_height="wrap_content">
                        </TextView>
                    </LinearLayout>
                </LinearLayout>
                <!--L1-->
                <LinearLayout
                    android:layout_marginLeft="25dp"
                    android:gravity="center"
                    android:layout_weight="1"
                    android:layout_width="160dp"
                    android:orientation="horizontal"
                    android:background="@drawable/shape_corner"
                    android:layout_height="105dp">
                    <ImageView
                        android:layout_weight="1"
                        android:layout_width="80dp"
                        android:layout_height="80dp"
                        android:layout_marginTop="10dp"
                        android:src="@drawable/k2"
                        android:layout_marginRight="15dp">
                    </ImageView>
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:orientation="vertical"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_marginRight="5dp"
                            android:layout_width="wrap_content"
                            android:text="土壤含钾"
                            android:textSize="20sp"
                            android:layout_height="wrap_content">
                        </TextView>
                        <TextView
                            android:id="@+id/soil_k"
                            android:layout_width="wrap_content"
                            android:text=" 0 "
                            android:textSize="25sp"
                            android:layout_height="wrap_content">
                        </TextView>
                    </LinearLayout>
                </LinearLayout>
                <!--Layout2-->
            </LinearLayout>
            <!-- The End -->
        </LinearLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

效果如下:

在这里插入图片描述

MainActitive.java 主要代码如下:

package com.example.ks_wfs;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.net.wifi.aware.DiscoverySession;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.concurrent.ScheduledExecutorService;
public class MainActivity extends AppCompatActivity {
    private Handler handler;
    private String serverUri = "自己的IP地址";
/*    private String serverUri = "tcp://iot.qaeb.cn:1883";*/
    /*
          这里可以填上各种云平台的物联网云平的域名+1883端口号,什么阿里云腾讯云百度云天工物接入都可以,
          这里我填的是我在我的阿里云服务器上搭建的EMQ平台的地址,
          注意:前缀“tcp://”不可少,之前我没写,怎么都连不上,折腾了好久
    */
    private String userName = " ";
    private String passWord = " ";
    private String clientId = "app"+System.currentTimeMillis(); //clientId很重要,不能重复,否则就会连不上,所以我定义成 app+当前时间
    private String mqtt_sub_topic = "/iotsoil/post";          //需要订阅的主题
    private String mqtt_pub_topic = "xiao";                  //需要发布的主题
    private MqttClient mqtt_client;                         //创建一个mqtt_client对象
    MqttConnectOptions options;
    private  TextView air_temp;
    private  TextView air_humi;
    private  TextView sloi_humi;
    private  TextView soli_n;
    private  TextView soil_p;
    private  TextView soil_k;
    private ImageView test;
    private ScheduledExecutorService scheduler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*
         * xiaobai
         * 2023.10.10
         * Version V1.0
         */
        /*绑定UI文件*/
        UI_Init();/*类似单片机的初始化*/
        mqtt_init_Connect();/*初始化连接函数*/
        /*回调函数,数据会在回调函数里面*/
        mqtt_client.setCallback(new MqttCallback() {
            @Override
            public void connectionLost(Throwable throwable) {
            }
            @Override
            public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
                /*数据到这了*/
                final String msg = new String(mqttMessage.getPayload());
                Log.d("MQTTRCV", msg);//日志信息,可以查看
                System.out.println(msg);/*打印得到的数据*/
                /*更新UI线程*/
 /*               runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                            *//*开始解析数据*//*
                           *//*数据解析部分这里使用的是Json解析*//*
                           *//*为了避免闪退,使用try来处理异常情况*//*
                        try {
                            JSONObject jsonObject = new JSONObject(String.valueOf(msg));
                            String method = jsonObject.getString("method");
                            JSONObject params = jsonObject.getJSONObject("params");
                            int soilHumidity = params.getInt("soilHumidity");
                            int currentTemperature = params.getInt("CurrentTemperature");
                            int currentHumidity = params.getInt("CurrentHumidity");
                            int n = params.getInt("N");
                            int p = params.getInt("P");
                            int k = params.getInt("K");
                                    *//*更新数据到UI*//*
                            air_temp.setText(String.valueOf(currentTemperature));
                            air_humi.setText(String.valueOf(currentHumidity));
                            sloi_humi.setText(String.valueOf(soilHumidity));
                            soli_n.setText(String.valueOf(n));
                            soil_p.setText(String.valueOf(p));
                            soil_k.setText(String.valueOf(k));
                                    *//*打印日志信息*//*
                            Log.d("TAG", "method: " + method);
                            Log.d("TAG", "soilHumidity: " + soilHumidity);
                            Log.d("TAG", "currentTemperature: " + currentTemperature);
                            Log.d("TAG", "currentHumidity: " + currentHumidity);
                            Log.d("TAG", "N: " + n);
                            Log.d("TAG", "P: " + p);
                            Log.d("TAG", "K: " + k);

                        }catch (JSONException e)
                        {
                            e.printStackTrace();
                            Toast.makeText(MainActivity.this ,"数据解析异常!",Toast.LENGTH_LONG).show();
                        }
                    }
                });*/
                /*下面是带弹窗显示的代码数据已经解析完成,解开注释即可*/

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                        builder.setTitle("MQTT消息");
                        builder.setMessage(msg);
                        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                // 点击确定按钮后的操作
                             /*   开始解析数据*/
                            /*    数据解析部分这里使用的是Json解析
                                为了避免闪退,使用try来处理异常情况*/
                                try {
                                    JSONObject jsonObject = new JSONObject(String.valueOf(msg));
                                    String method = jsonObject.getString("method");
                                    JSONObject params = jsonObject.getJSONObject("params");
                                    int soilHumidity = params.getInt("soilHumidity");
                                    int currentTemperature = params.getInt("CurrentTemperature");
                                    int currentHumidity = params.getInt("CurrentHumidity");
                                    int n = params.getInt("N");
                                    int p = params.getInt("P");
                                    int k = params.getInt("K");
                               /*     更新UI*/
                                    air_temp.setText(String.valueOf(currentTemperature));
                                    air_humi.setText(String.valueOf(currentHumidity));
                                    sloi_humi.setText(String.valueOf(soilHumidity));
                                    soli_n.setText(String.valueOf(n));
                                    soil_p.setText(String.valueOf(p));
                                    soil_k.setText(String.valueOf(k));
                               /*     打印输出的信息*/
                                    Log.d("TAG", "method: " + method);
                                    Log.d("TAG", "soilHumidity: " + soilHumidity);
                                    Log.d("TAG", "currentTemperature: " + currentTemperature);
                                    Log.d("TAG", "currentHumidity: " + currentHumidity);
                                    Log.d("TAG", "N: " + n);
                                    Log.d("TAG", "P: " + p);
                                    Log.d("TAG", "K: " + k);

                                }catch (JSONException e)
                                {
                                    e.printStackTrace();
                                    Toast.makeText(MainActivity.this ,"数据解析异常!",Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                        builder.show();
                    }
                });
            }
            @Override
            public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
            }
        });
        /*点击事件*/
        test.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PublishMessage(mqtt_pub_topic,"{\"params\":{\"我是小白,你好呀\":999 } }");
            }
        });

    }
    public void mqtt_init_Connect()
    {
        try {
            //实例化mqtt_client,填入我们定义的serverUri和clientId,然后MemoryPersistence设置clientid的保存形式,默认为以内存保存
            mqtt_client = new MqttClient(serverUri,clientId,new MemoryPersistence());
            //创建并实例化一个MQTT的连接参数对象
            options = new MqttConnectOptions();
            //然后设置对应的参数
            options.setUserName(userName);                  //设置连接的用户名
            options.setPassword(passWord.toCharArray());    //设置连接的密码
            options.setConnectionTimeout(30);               // 设置超时时间,单位为秒
            options.setKeepAliveInterval(50);               //设置心跳,30s
            options.setAutomaticReconnect(true);            //是否重连
            //设置是否清空session,设置为false表示服务器会保留客户端的连接记录,设置为true表示每次连接到服务器都以新的身份连接
            options.setCleanSession(false);
            /*初始化成功之后就开始连接*/
            connect();
            Toast.makeText(MainActivity.this,"连接成功",Toast.LENGTH_LONG).show();
        }catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(MainActivity.this,"失败",Toast.LENGTH_LONG).show();
        }
    }
    public void connect(){
        //连接mqtt服务器
        try {
            mqtt_client.connect(options);
            mqtt_client.subscribe(mqtt_sub_topic);
            Toast.makeText(this ,"开始建立连接.....!",Toast.LENGTH_LONG).show();
        }catch (Exception e) {
            e.printStackTrace();
            Log.d("MQTTCon","mqtt连接失败");
            Toast.makeText(this ,"mqtt连接失败!",Toast.LENGTH_LONG).show();
        }
    }
    /*绑定各个UI控件*/
    public void UI_Init()
    {
        air_temp  =  findViewById(R.id.air_temp); //空气温度
        air_humi  =  findViewById(R.id.air_humi);//空气湿度
        sloi_humi =  findViewById(R.id.sloi_humi);//土壤湿度
        soli_n    =  findViewById(R.id.soli_n);//土壤含N量
        soil_p    =  findViewById(R.id.soil_p);//土壤含P量
        soil_k    =  findViewById(R.id.soil_k);//土壤含K量
        test      =  findViewById(R.id.test);//测试按钮
    }
    /*发布函数!*/
    private void PublishMessage(String topic,String Message2)
    {
        if(mqtt_client ==null || !mqtt_client.isConnected())
        {
            return;
        }
        MqttMessage message = new MqttMessage();
        message.setPayload(Message2.getBytes());
        try{
            mqtt_client.publish(topic,message);

        }catch (MqttException e)
        {
            e.printStackTrace();
        }
    }

}

End

完整的代码工程可以进QQ群获取!
764452437

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

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

相关文章

PTrade财务数据获取函数的问题

前文介绍了PTrade的get_fundamentals函数&#xff0c;可以用于获取股票的财务数据。但在实际应用中&#xff0c;会遇到如下的问题。 前文我们通过将回测时间设置为2023-05-05进行回测调用get_fundamentals&#xff0c;得到如下查询结果&#xff1a; secu_codepubl_dateend_da…

ThingsBoard 实现设备认领

1. 设备认领的使用场景 设备认领在一种场景下使用,当租户已经生产好设备时,租户把设备卖给了客户, 客户通过认领的方式将设备划分到自己下面,客户变成设备的拥有者。 2. 设备认领的方式 设备认领的方式存在两种: 设备生成密钥 和 服务端生成密钥 2.1. 设备生成密钥 设备…

Zookeeper+Hadoop+Spark+Flink+Kafka+Hbase+Hive 完全分布式高可用集群搭建(保姆级超详细含图文)

说明: 本篇将详细介绍用二进制安装包部署hadoop等组件&#xff0c;注意事项&#xff0c;各组件的使用&#xff0c;常用的一些命令&#xff0c;以及在部署中遇到的问题解决思路等等&#xff0c;都将详细介绍。 1.环境说明 1.1 ip规划 iphostname192.168.1.11node1192.168.1.…

来看看如何使用Proton_实现网络聚合_利用安全的网络协议实现网络通讯---工具箱工作笔记001

首先要去注册proton.com 注册的时候首先去注册一个proton的邮箱@protonmail.com这个邮箱 注册以后进入,然后选择中文 然后再去下载这个CDN加速网址 去下载了以后 选择左侧免费的就可以了

升级版多功能版在线WEB工具箱PHP源码/在线站长工具箱源码/php多功能引流工具箱源码

源码简介&#xff1a; 升级版多功能版在线WEB工具箱PHP源码&#xff0c;这是最新的在线站长工具箱源码&#xff0c;它是一款PHP多功能引流工具箱源码。作为一个多功能的Web工具PHP脚本&#xff0c;包含45种工具&#xff0c;适用于平常任务和开发人员&#xff0c;或者用来推广引…

公有云厂商---服务对照表

各厂商特点&#xff1a; Compute: Network: Storage: Database: Migration Tool: Identify: WAF: 来源&#xff1a;https://comparecloud.in/

p-limit源码解读--30行代码,高大上解决Promise的多并发问题

背景 提起控制并发&#xff0c;大家应该不陌生&#xff0c;我们可以先来看看多并发&#xff0c;再去聊聊为什么要去控制它 多并发一般是指多个异步操作同时进行&#xff0c;而运行的环境中资源是有限的&#xff0c;短时间内过多的并发&#xff0c;会对所运行的环境造成很大的…

《算法通关村第二关——指定区间反转问题解析》

《算法通关村第二关——指定区间反转问题解析》 题目描述 给你单链表的头指针head和两个整数left和right&#xff0c;其中left < right 。 请你反转从位置left到位置right的链表节点&#xff0c;返回反转后的链表。 示例1&#xff1a; 输入&#xff1a; head [1,2,3,4,5…

打工人必备技能——找资源~

让我看看还有哪个打工人不会找资源&#xff0c;不过没关系&#xff0c;相信看完我这篇内容&#xff0c;不会的也学会了&#xff01; 一、XDown 全网1000平台视频解析下载器&#xff0c;在线视频下载工具&#xff0c;几乎能下全网所有平台的视频&#xff0c;而且下完还能自由转…

HammerDB的安装和使用(超详细)

目录 ​编辑 一、HammerDB的介绍 二、HammerDB的安装 1、下载hammerdb安装包 2、权限配置以及安装 3、查看安装目录 三、安装前的配置 1、启动监听 2、启动数据库 3、创建表空间 1.修改临时表空间 2…

STM32F4之系统滴答定时器

一、系统滴答定时器概述 传统定时器&#xff1a;如手机闹钟&#xff0c;闹钟等就是一个简单地计数器。 定时器概念&#xff1a;由时钟源计数器计数值组成的计数单元。 系统嘀嗒定时器首先是存在于内核里&#xff0c;系统嘀嗒时钟假如用的是同一个内核那么里面相关的配置&…

移动端web调试工具vConsole使用详解

目录 简介&#xff1a; 使用 方法一&#xff1a;使用 npm&#xff08;推荐&#xff09; 方法二&#xff1a;使用 CDN 直接插入到 HTML 开发环境显示生成环境删除 vConsole是框架无关的&#xff0c;可以在 Vue、React 或其他任何框架中使用&#xff0c;类似于微信小程序体验…

《计算机是怎样跑起来的》计算机三大原则、TCP/IP、xml

文章目录 计算机的三个根本基础TCP/IP 网络的简单理解向路由器更进一步DNS服务器IP 地址和 MAC 地址的对应关系TCP 的作用以及 TCP/IP网络的层级模型 基本概念的阐述XML定义优势结构 计算机的三个根本基础 计算机是执行输入、运算、输出的机器。 计算机的硬件由大量集成电路 IC…

【C语言】进阶——程序编译

目录 一&#xff1a;&#x1f512;程序环境 程序的翻译环境和执行环境 &#x1f4a1;1.1翻译环境 预编译阶段&#xff1a; 编译阶段&#xff1a; 汇编阶段&#xff1a; 链接阶段&#xff1a; &#x1f4a1;1.2运行环境 二&#xff1a;&#x1f512;预处理详解 &…

进阶JAVA篇-深入了解 Set 系列集合

目录 1.0 Set 类的说明 1.1 Set 类的特点 1.2 Set 类的常用API 2.0 HashSet 集合的说明 2.1 从 HashSet 集合的底层原理来解释是如何实现该特性 2.2 HashSet 集合的优缺点 2.3 深入理解 HashSet 集合去重的机制 2.4 如何快速编写已经重写好的 hashCode 和 equals 方法 3.0 Tree…

空中计算(Over-the-Air Computation)学习笔记

文章目录 写在前面 写在前面 本文是论文A Survey on Over-the-Air Computation的阅读笔记&#xff1a; 通信和计算通常被视为独立的任务。 从工程的角度来看&#xff0c;这种方法是非常有效的&#xff0c;因为可以执行孤立的优化。 然而&#xff0c;对于许多面向计算的应用程序…

【Arduino TFT】基于 ESP32S3 S7789 240x240 TFT实现的SD2 天气时钟

忘记过去&#xff0c;超越自己 ❤️ 博客主页 单片机菜鸟哥&#xff0c;一个野生非专业硬件IOT爱好者 ❤️❤️ 本篇创建记录 2023-10-21 ❤️❤️ 本篇更新记录 2023-10-21 ❤️&#x1f389; 欢迎关注 &#x1f50e;点赞 &#x1f44d;收藏 ⭐️留言&#x1f4dd;&#x1f64…

口袋参谋:如何找蓝海词?带动店铺搜索流量!

​为什么店铺没流量&#xff1f;很多新手商家在优化标题的时候从来不找词&#xff0c;凭着自己的想象做标题&#xff0c;这种情况很难获得流量。 要想获得更多的流量&#xff0c;符合产品属性的蓝海词是我们当属首选&#xff0c;不用和红海词去竞争&#xff0c;更不用和比较有…

java springboot+VUE OA企业办公自动化系统前后端分离开发mysql数据库web结构java编程计算机网页源码maven项目

一、源码特点 springboot VUE OA企业办公自动化系统是一套完善的完整信息管理类型系统&#xff0c;结合springboot框架和VUE完成本系统 后端采用mybatis进行数据库交互&#xff0c;对理解JSP java编程开发语言有帮 助系统采用springboot框架&#xff08;MVC模式开发&#xff…

Pandas数据处理分析系列4-数据如何清洗

Pandas-数据清洗 ①缺失值处理 使用fillna()函数将缺失值替换为指定的值或使用插值方法填充缺失值 示例:df.fillna(0) #将缺失值替换为0 import pandas as pddf1=pd.read_excel("销售表.xlsx") # 检查每列是否缺失 print(df1.isna) 效果如下: import pandas as …