greendao实现增删改查

说明:最近碰到一个需求,在安卓上使用greendao框架,实现增删改查数据

效果图:
在这里插入图片描述

step1:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"
        classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

step2:

plugins {
    id 'com.android.application'
    id 'org.greenrobot.greendao'
}

android {
    compileSdkVersion 32

    defaultConfig {
        applicationId "com.example.iosdialogdemo"
        minSdkVersion 16
        targetSdkVersion 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

greendao {
    schemaVersion 7
    daoPackage 'com.example.iosdialogdemo'
    targetGenDir 'src/main/java'
}


dependencies {

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'org.greenrobot:greendao:3.2.2'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

}

step3:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.iosdialogdemo">

    <application
        android:name=".GreenApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.IosDialogDemo">
        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

step4:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:layout_margin="8dp"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal">


        <EditText
            android:id="@+id/etLanguage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingRight="8dp" />


        <Button
            android:id="@+id/btn_add"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:backgroundTint="@android:color/holo_purple"
            android:text="新增"
            android:textColor="@android:color/white" />
        <Button
            android:id="@+id/btn_update"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:backgroundTint="@android:color/holo_purple"
            android:text="修改"
            android:textColor="@android:color/white" />
    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvLanguage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:listitem="@layout/item" />

</LinearLayout>

step5:

<?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="wrap_content"
    android:layout_marginBottom="16dp"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/tvOrderNumber"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:text="1"
        android:textColor="@color/white"
        android:background="@color/purple_200"
        app:layout_constraintBottom_toBottomOf="@+id/tvLanguage"
        app:layout_constraintEnd_toStartOf="@+id/tvLanguage"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/tvLanguage" />

    <TextView
        android:id="@+id/tvLanguage"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Bahasa"
        android:textColor="@color/white"
        android:background="@color/teal_200"
        app:layout_constraintBottom_toBottomOf="@+id/btnDelete"
        app:layout_constraintEnd_toStartOf="@+id/btnDelete"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/tvOrderNumber"
        app:layout_constraintTop_toTopOf="@+id/btnDelete" />

    <Button
        android:id="@+id/btnDelete"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:text="删除"
        android:backgroundTint="@android:color/holo_blue_dark"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/tvLanguage"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

step6:

package com.example.iosdialogdemo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 7): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 7;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        UserDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        UserDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(UserDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}

step7:

package com.example.iosdialogdemo;

import java.util.Map;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.AbstractDaoSession;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;

import com.example.iosdialogdemo.User;

import com.example.iosdialogdemo.UserDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see org.greenrobot.greendao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig userDaoConfig;

    private final UserDao userDao;

    public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        userDaoConfig = daoConfigMap.get(UserDao.class).clone();
        userDaoConfig.initIdentityScope(type);

        userDao = new UserDao(userDaoConfig, this);

        registerDao(User.class, userDao);
    }
    
    public void clear() {
        userDaoConfig.clearIdentityScope();
    }

    public UserDao getUserDao() {
        return userDao;
    }

}

step8:

package com.example.iosdialogdemo;

import android.app.Application;
import org.greenrobot.greendao.database.Database;


/**
 * Created by rhodel on 8/15/2017.
 */

public class GreenApp extends Application {

    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();

        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db");
        Database db = helper.getWritableDb();
        daoSession = new DaoMaster(db).newSession();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        daoSession.clear();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}

step9:

package com.example.iosdialogdemo;



public interface ILanguageRecycleListener {
    void itemOnClick(int model,Long id,String title,int position);
    /* mode1 0:id,1:title,2:delete*/
}

step10:

package com.example.iosdialogdemo;


        import android.util.Log;
        import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;

        import androidx.annotation.NonNull;
        import androidx.recyclerview.widget.RecyclerView;

        import java.util.ArrayList;
        import java.util.List;

public class LanguageRecycleAdapter extends RecyclerView.Adapter<LanguageViewHolder> {

    private List<User> languageList = new ArrayList<>();

    private ILanguageRecycleListener listener;

    public LanguageRecycleAdapter(List<User> languageList, ILanguageRecycleListener listener) {
        this.languageList = languageList;
        this.listener = listener;

        Log.e("TAG", "LanguageRecycleAdapter " + languageList.size());
    }

    public void setData(List<User> languageList2) {
        this.languageList = languageList2;
    }

    @NonNull
    @Override
    public LanguageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LanguageViewHolder holder;
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
        holder = new LanguageViewHolder(view);
        return holder;

    }

    @Override
    public void onBindViewHolder(@NonNull LanguageViewHolder holder, final int position) {
        holder.orderNumber.setText(String.valueOf(position));
        holder.language.setText(languageList.get(position).getName());
        holder.orderNumber.setText(String.valueOf(languageList.get(position).getId()));


        holder.btnDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.itemOnClick(2,languageList.get(position).getId(),languageList.get(position).getName(),position);
            }
        });
        holder.orderNumber.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.itemOnClick(0,languageList.get(position).getId(),languageList.get(position).getName(),position);
            }
        });

        holder.language.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.itemOnClick(1,languageList.get(position).getId(),languageList.get(position).getName(),position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return languageList.size();
    }


}

step11:

package com.example.iosdialogdemo;



        import android.view.View;
        import android.widget.Button;
        import android.widget.TextView;

        import androidx.annotation.NonNull;
        import androidx.recyclerview.widget.RecyclerView;

public class LanguageViewHolder extends RecyclerView.ViewHolder {
    TextView orderNumber;
    TextView language;
    Button btnDelete;

    public LanguageViewHolder(@NonNull View itemView) {
        super(itemView);
        orderNumber = itemView.findViewById(R.id.tvOrderNumber);
        language = itemView.findViewById(R.id.tvLanguage);
        btnDelete = itemView.findViewById(R.id.btnDelete);
    }
}

step12:

package com.example.iosdialogdemo;



        import androidx.appcompat.app.AppCompatActivity;
        import androidx.recyclerview.widget.LinearLayoutManager;
        import androidx.recyclerview.widget.RecyclerView;

        import android.os.Bundle;
        import android.util.Log;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;

        import java.util.ArrayList;
        import java.util.List;

public class MainActivity extends AppCompatActivity implements ILanguageRecycleListener {
    private LanguageRecycleAdapter languageRecycleAdapter;
    private RecyclerView rvLanguage;
//    private List<String> languageList = new ArrayList<>();
    private EditText editText;
    private Button btn_add,btn_update;
    private UserDao userDao;
    private DaoSession daoSession;

    private List<User> languageList;
    private Long id2;
    private String title2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        daoSession = ((GreenApp) getApplication()).getDaoSession();
        userDao = daoSession.getUserDao();

        languageList = new ArrayList<>();

        if (languageList!=null){
            languageList.clear();
        }

        languageList.addAll(userDao.queryBuilder().list());



        rvLanguage = findViewById(R.id.rvLanguage);
        editText= findViewById(R.id.etLanguage);
        btn_add= findViewById(R.id.btn_add);
        btn_update= findViewById(R.id.btn_update);

        RecyclerView.LayoutManager layoutManager = new
                LinearLayoutManager(this);
        rvLanguage.setLayoutManager(layoutManager);
        languageRecycleAdapter = new LanguageRecycleAdapter(languageList, this);
        rvLanguage.setAdapter(languageRecycleAdapter);

        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String etString = editText.getText().toString();
               // languageList.add(etString);

                User user = new User();
                user.setName(etString);


                userDao.insert(user);


                if (languageList!=null){
                    languageList.clear();
                }

                languageList.addAll(userDao.queryBuilder().list());



                languageRecycleAdapter.setData(languageList);
                languageRecycleAdapter.notifyDataSetChanged();
            }
        });


        btn_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String etString = editText.getText().toString();
                // languageList.add(etString);
                Log.e("TAG", "sql_itemOnClick: " +id2+"==="+title2);

                User user = new User();
                user.setName(etString);
                user.setId(id2);


                userDao.update(user);


                if (languageList!=null){
                    languageList.clear();
                }

                languageList.addAll(userDao.queryBuilder().list());



                languageRecycleAdapter.setData(languageList);
                languageRecycleAdapter.notifyDataSetChanged();
            }
        });
    }

    @Override
    public void itemOnClick(int model,Long id, String title,int position) {
        Log.e("TAG", "itemOnClick: " + id + ", " + position);
        if (model==2){

            userDao.deleteByKey(id);

            if (languageList!=null){
                languageList.clear();
            }

            languageList.addAll(userDao.queryBuilder().list());


            Log.e("TAG", "sql_itemOnClick: " +languageList);


            languageRecycleAdapter.setData(languageList);
            languageRecycleAdapter.notifyDataSetChanged();

          /*  languageList.remove(position);
            languageRecycleAdapter.setData(languageList);
            languageRecycleAdapter.notifyDataSetChanged();*/
        }else if (model==1){
            editText.setText(title);

            id2 = id;
            title2=title;
        }
    }
}

step13:

package com.example.iosdialogdemo;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

/**
 * Created by rhodel on 8/15/2017.
 */

@Entity
public class User {
    @Id(autoincrement = true)
    private Long id;

    private String name;

    @Generated(hash = 873297011)
    public User(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    @Generated(hash = 586692638)
    public User() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

step14:

package com.example.iosdialogdemo;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "USER".
*/
public class UserDao extends AbstractDao<User, Long> {

    public static final String TABLENAME = "USER";

    /**
     * Properties of entity User.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Name = new Property(1, String.class, "name", false, "NAME");
    }


    public UserDao(DaoConfig config) {
        super(config);
    }
    
    public UserDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"USER\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"NAME\" TEXT);"); // 1: name
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"USER\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, User entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, User entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public User readEntity(Cursor cursor, int offset) {
        User entity = new User( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1) // name
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, User entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(User entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(User entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(User entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}

end

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用nexus搭建的docker私库,定期清理无用的镜像,彻底释放磁盘空间

一、背景 我们使用nexus搭建了docker镜像&#xff0c;随着推送的镜像数量越来越多&#xff0c;导致nexus服务器的磁盘空间不够用了。于是&#xff0c;我们急需先手动删除一些过期的镜像&#xff0c;可发现磁盘空间并没有释放。 那么&#xff0c;如何才能彻底释放掉呢&#xff…

Android - failed to set system property

记录一次疏忽&#xff0c;起因是我需要在自定义的 receiver 中保存 property 方便&#xff0c;方便在三方 app 中使用&#xff0c;结果直接崩溃了&#xff0c;虽然结果保存成功了&#xff0c;但是这种情况也是无法接收的&#xff0c;错误日志如下&#xff1a; M006082 05-25 1…

[数据集][目标检测]航空发动机缺陷检测数据集VOC+YOLO格式291张4类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;291 标注数量(xml文件个数)&#xff1a;291 标注数量(txt文件个数)&#xff1a;291 标注类别…

Python 点云处理-点云半径滤波

点云半径滤波 一、介绍二、代码示例三、结果示例其他参考:C++ 中点云半径滤波 一、介绍 点云半径滤波:删除点云一定范围内没有达到足够多领域的所有点云。通俗的讲:就是要求点云P在半径为R内需要有M个领域点,若在点P的R范围内领域点个数大于M个,则保留该点云,领域点个数…

拌合楼系统开发(二十)解决海康DS-TVL224系列屏幕显示二维码思路

前言&#xff1a; 需求是想在通过程序动态控制显示屏显示二维码&#xff0c;最开始有些担心led这种点阵屏会不会对二维码显示出来后无法识别&#xff0c;实际测时候发现是没问题的。对于显示文字和语音播报&#xff0c;csdn上已经有大神有完整的代码。 海康威视道闸进出口LED屏…

java高级——String字符串探索(在jvm底层中如何实现,常量池中怎么查看)

java高级——String字符串探索&#xff08;在jvm底层中如何实现&#xff0c;常量池中怎么查看&#xff09; 文章介绍提前了解的知识点1. 常量池2. Jvm虚拟机3. 字节码 String类详解1. String对象在申明后将不可修改&#xff0c;是不可变类2. String进行相加相减等操作时一定会创…

常见的螺纹防松措施有哪些?——SunTorque智能扭矩系统

智能扭矩系统-智能拧紧系统-扭矩自动控制系统-SunTorque 螺纹连接作为机械工程中常见的连接方式&#xff0c;其稳定性和可靠性对于整个机械系统的正常运行至关重要。然而&#xff0c;由于振动、冲击、温度变化等因素的影响&#xff0c;螺纹连接往往会出现松动现象&#xff0c;…

react中子传父信息

思路是&#xff1a; 在父组件定义一个函数接受参数&#xff0c;接收的参数用于接收子组件的信息&#xff0c;把函数传给子组件&#xff0c;子组件调用父亲传来的函数并把要告诉父亲的话传到函数中&#xff0c;就实现了子传父消息 import { useState } from reactimport { use…

C++学习/复习7--泛型编程/函数模板/类模板

一、泛型编程 1.Swap()函数的模板实现 二、函数模板 1.概念 2.格式 3.实例化 &#xff08;1&#xff09;隐式与显示 注意事项&#xff1a;隐式与显示类型转换会产生临时变量&#xff0c;临时变量有常性&#xff0c;所以形参前加const 三、类模板 1.定义 2.例1 3.例2 4.注意事…

nginx流量监控:goAccess安装与使用

关于goAccess GoAccess 是一款实时、快速的日志分析工具&#xff0c;专门设计用于分析Web服务器日志&#xff0c;特别是Nginx日志。 安装 &#xff08;1&#xff09;准备相关依赖 # Missing development libraries for ncursesw # centOS yum install -y ncurses-devel # U…

qmt量化交易策略小白学习笔记第7期【qmt策略之股票快照指标】

qmt策略之股票快照指标 qmt更加详细的教程方法&#xff0c;会持续慢慢梳理。 也可找寻博主的历史文章&#xff0c;搜索关键词查看解决方案 &#xff01; 感谢关注&#xff0c;需免费开通量化回测与咨询实盘权限&#xff0c;可以和博主联系&#xff01; 股票快照指标 提供标…

python双色球选号程序的实现与解析

新书上架~&#x1f447;全国包邮奥~ python实用小工具开发教程http://pythontoolsteach.com/3 欢迎关注我&#x1f446;&#xff0c;收藏下次不迷路┗|&#xff40;O′|┛ 嗷~~ 目录 一、引言&#xff1a;双色球选号游戏的魅力 二、程序设计与实现 1. 生成红色球号码 2. 生…

OpenHarmony迎来首个互联网技术统一标准,鸿蒙OS生态走向如何?

开源三年半&#xff0c;OpenHarmony(以下简称“开源鸿蒙”)迎来了新进展。在5月25日召开的「OpenHarmony开发者大会」上&#xff0c;鸿蒙官宣了开源鸿蒙设备统一互联技术标准。 一直以来&#xff0c;各行业品牌操作系统相互独立、难以协同,成为其互联互通的痛点。为进一步解决…

USST新生训练赛div2+div3题解

目录 前言题解部分B Ichihime and Triangle(800)题目大意题解代码实现 C Kana and Dragon Quest game(900)题目大意题解代码实现 J Squares and Cubes(800)题目大意题解代码实现 F Double Sort(1200)题目大意题解代码实现 I Minimize the Thickness(1100)题目大意题解代码实现 …

华为CE6851-48S6Q-HI升级设备版本及补丁

文章目录 升级前准备工作笔记本和交换机设备配置互联地址启用FTP设备访问FTP设备升级系统版本及补丁 升级前准备工作 使用MobaXterm远程工具连接设备&#xff0c;并作为FTP服务器准备升级所需的版本文件及补丁文件 笔记本和交换机设备配置互联地址 在交换机接口配置IP&#…

LAMP源码编译安装——CentOS7

文章目录 LAMP是什么LAMP软件组件LinuxApacheMySQLPHP 源码安装Apache一、准备工作二、安装环境依赖包三、配置软件模块四、编译及安装五、优化配置文件路径六、添加httpd系统服务&#xff08;有两种方法&#xff09;方法一&#xff1a;方法二&#xff1a; 七、修改httpd 服务配…

LabVIEW软件需求分析文档内容和编写指南

编写LabVIEW软件需求分析文档&#xff08;Software Requirements Specification, SRS&#xff09;是软件开发的关键步骤之一。以下是详细的内容结构、编写指南和注意事项&#xff1a; 内容结构 引言 项目背景&#xff1a;简要介绍项目背景和目的。 文档目的&#xff1a;说明需…

利用NewGIS平台将FME模板发布为接口

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 前言 一、模板编写 二、发布模板 三、接口获取 四、移动端调用 ​​​​​ 前言 在实际的应用生产过程中&#xff0c;尤其是移动端GIS软件的开发&#xff0c;针对一些闭…

C++学习笔记(21)——继承

目录 1. 继承的概念及定义1.1 继承的概念1.2 继承定义1.2.1 定义格式1.2.2 继承关系和访问限定符1.2.3 继承基类成员访问方式的变化 继承的概念总结&#xff1a; 2. 基类和派生类对象赋值转换3.继承中的作用域4.派生类的默认成员函数知识点&#xff1a;派生类中6个默认成员函数…

头文件大小写引发的报错

jenkins下打包编译报错如下&#xff0c;提示编译zynqCan.c时找不到“syscfgpll/sysCfgpll.h”文件。 但IDE下编译是没有报错也没有警告的&#xff0c;工程中也存在文件“syscfgpll/sysCfgPll.h”。 仔细观察发现&#xff0c;报错说的是找不到头文件“syscfgpll/sysCfgpll.h”…