Springboot same annotation call. the variable member value is 0

My depedency injection @repository gives 0 value with @autowired

@Repository public class AbsensiRepo{ public double jarakStandardMasukDanPulang = 4.5; }  @Repository public class RekapKehadiranRepo { @Autowired AbsensiRepo absensiRepo;   public double ShowOtherDIVariable(){   double test = 1*absensiRepo.jarakStandardMasukDanPulang;   return test;  } } 

when i run ShowOtherDIVariable() the result is 0; and the variable absensiRepo.jarakStandardMasukDanPulang has value 0.

Why is that? is the jarakStandardMasukDanPulang from class AbsensiRepo is not finished yet when i call it?

how to solve it, so the absensiRepo.jarakStandardMasukDanPulang value will be 4.5 like its original?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.