Gradle 或 jackson fasterxml @JsonProperty 不工作

Gradle or jackson fasterxml @JsonProperty not working

Android 使用 Androidx Java、Gradle 和 Firebase 进行应用程序开发。

请帮我找出为什么 @JsonProperty 不起作用。

Gradle 已成功设置 fasterxml 库。
没有编译时错误或运行时错误。
FasterXML 库也已安装并存在。

但是@JsonProperty 和@Jsonignore 不起作用。
因此,不是使用在@JsonProperty 中声明的名称存储数据,
数据以变量名存储到 firebase 中。

并且@JsonIgnore 不会忽略变量,
它们也存储在 firebase 中。

下面是build.gradle,请帮我找出根本原因。

apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/checkstyle.gradle"
apply from: "$project.rootDir/tools/pmd.gradle"

repositories {
   google()
   mavenCentral()
   maven {
            url "https://repo.spring.io/libs-milestone/"
   }
   maven {
            url "https://repository.mulesoft.org/nexus/content/repositories/public/"
   }
}

android {
    lintOptions {
        abortOnError false
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'        
        resolutionStrategy.force 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
        resolutionStrategy.force 'com.fasterxml.jackson.core:jackson-core:2.2.2'
        resolutionStrategy.force 'com.fasterxml.jackson.core:jackson-annotations:2.2.2'
    }
    signingConfigs {
        config {
            keyAlias '*****'
            keyPassword '*****'
            storeFile file('*****')
            storePassword '*****'
        }
    }
    flavorDimensions "default"
    compileSdkVersion 30
    defaultConfig {
        applicationId "*****"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 17
        versionName "Basilisk-prd"
        signingConfig signingConfigs.config
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            testCoverageEnabled = true
        }
    }
    productFlavors {
        staging {
            applicationIdSuffix ""
            versionNameSuffix "-stg"
        }

        production {
            applicationIdSuffix ""
            versionNameSuffix "-prd"
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/androidx.*'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    buildToolsVersion '30.0.1'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    androidTestImplementation 'androidx.annotation:annotation:1.0.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    implementation('commons-lang:commons-lang:2.6') {
        exclude group: 'commons-io', module: 'commons-io'
    }

    //Butterknife
    implementation 'com.jakewharton:butterknife:10.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'

    //Dagger2
    implementation 'com.google.dagger:dagger:2.15'
    implementation 'com.google.dagger:dagger-android:2.15'
    implementation 'com.google.dagger:dagger-android-support:2.15'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.15'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.15'

    // Architecture
    implementation 'androidx.lifecycle:lifecycle-runtime:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'

    // RX Java
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

    implementation 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.2.2'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.2.2'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.2.2'

    implementation platform('com.google.firebase:firebase-bom:26.1.0')
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-database'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'commons-io:commons-io:2.4'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'me.dm7.barcodescanner:zxing:1.8.4'
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.3.0@aar'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'com.github.bumptech.glide:glide:4.2.0'

    // (AH) for HTTP requests
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
}

apply plugin: 'com.google.gms.google-services'

最新的 Firebase 数据库不再使用来自 fasterxml jackson 注释的 @JsonProperty @JsonIgnore。

改为使用@PropertyName @Exclude @IgnoreExtraProperties 来自包 com.google.firebase.database