gpt4 book ai didi

java - 重复的 : No setter/field for found on class

转载 作者:搜寻专家 更新时间:2023-11-01 07:43:09 24 4
gpt4 key购买 nike

当我尝试使用 Firebase 获取数据时遇到了这个问题:

No setter/field for 0C:F3:EE:12:E0:4C found on class com.school.models.EmBeacon

No setter/field for 0C:F3:EE:12:E0:5C found on class com.school.models.EmBeacon

No setter/field for 0C:F3:EE:12:E0:E5 found on class com.school.models.EmBeacon

这是我的数据结构:

enter image description here

这是获取我所有数据的代码:

mDatabase.child("beacons").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
EmBeacon mBeacon = dataSnapshot.getValue(EmBeacon.class);
Log.i(TAG, "onDataChange: "+mBeacon);
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.w(TAG, "onCancelled:", databaseError.toException());
}
});

和类(class):

public class EmBeacon {

private String proximityUuid;
private int major;
private int minor;
private String addressMac;

public EmBeacon() {
}

public EmBeacon( String addressMac) {
this.addressMac = addressMac;
}

public EmBeacon(String proximityUuid, int major, int minor, String addressMac) {
this.proximityUuid = proximityUuid;
this.major = major;
this.minor = minor;
this.addressMac = addressMac;
}

public String getProximityUuid() {
return proximityUuid;
}

public void setProximityUuid(String proximityUuid) {
this.proximityUuid = proximityUuid;
}

public int getMajor() {
return major;
}

public void setMajor(int major) {
this.major = major;
}

public int getMinor() {
return minor;
}

public void setMinor(int minor) {
this.minor = minor;
}

public String getAddressMac() {
return addressMac;
}

public void setAddressMac(String addressMac) {
this.addressMac = addressMac;
}

@Override
public String toString() {
return "EmBeacon{" +
"proximityUuid='" + proximityUuid + '\'' +
", major='" + major + '\'' +
", minor='" + minor + '\'' +
", addressMac='" + addressMac + '\'' +
'}';

知道这里出了什么问题吗?

最佳答案

/beacons下有多个信标,所以你需要在你的onDataChange中循环它们:

mDatabase.child("beacons").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot beaconSnapshot: dataSnapshot.getChildren()) {
EmBeacon mBeacon = beaconSnapshot.getValue(EmBeacon.class);
Log.i(TAG, "onDataChange: "+mBeacon);
}
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.w(TAG, "onCancelled:", databaseError.toException());
}
});

关于java - 重复的 : No setter/field for found on class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51026552/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com