1.在project級別下 dependencies里
配置? ? classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
2.在module級別下配置build.gradle
配置到build.gradle頂部
apply plugin: 'org.greenrobot.greendao' // apply plugin 步驟3
? ? //配置到android模塊下
? ? greendao {
? ? ? ? //數(shù)據(jù)庫版本號,升級時修改
? ? ? ? schemaVersion 1
? ? ? ? //生成的DAO,DaoMaster和DaoSession的包路徑。默認(rèn)與表實體所在的包路徑相同
? ? ? ? daoPackage 'com.example.greendaodemo.db'
? ? ? ? //生成源文件的路徑。默認(rèn)源文件目錄是在build目錄中的(build/generated/source/greendao)
? ? ? ? targetGenDir 'src/main/java'
? ? }
? ? implementation 'org.greenrobot:greendao:3.2.2' // add library 數(shù)據(jù)庫依賴
? ? implementation 'org.greenrobot:greendao-generator:3.2.2'
3.編譯
4.創(chuàng)建? bean對象,添加注解標(biāo)簽(@Entity @Id)
5.編譯? make+project