Сделайте метод окружения «статическим» или удалите этот набор < /p>
< /blockquote>
Теперь, потому что переменные являются статическими, метод, в которых их значения являются статичными, но мы не можем быть статическими, но мы не можем быть статическими, но мы не можем быть. Autowovired < /p>
И если я сделаю переменную нестатической, то я получаю эту ошибку < /p>
Неожиданная ошибка произошла: произошла ошибка при обновлении пациента ORG. Не могу вызвать "com.docasap.patientmanagementservice.helpers.encryptdecrypthelper.buildencryptdecryptserviceimpl ()", потому что "это.
Код: Выделить всё
@Slf4j
@Component
public class StudentEventListener {
private static OptStudentRepo optStudentRepo;
private static IntStudentRepo intStudentRepo;
private static EncryptDecryptHelper encryptDecryptHelper;
@Autowired
public void setEncryptDecryptHelper(EncryptDecryptHelper encryptDecryptHelp) {
encryptDecryptHelper = encryptDecryptHelp;
}
@Autowired
public void setOasPatientRepo(IntStudentRepo intStudentRepo1) {
intStudentRepo = intStudentRepo1;
}
@Autowired
public void setOrgPatientRepo(OptStudentRepo optStudentRepo1) {
optStudentRepo = optStudentRepo1;
}
protected EncryptDecryptService determineEncryptionKey(StudentRecord sr) {
HashMap encIds = sr.getEncryptionIds(intStudentRepo, optStudentRepo);
EncryptDecryptService encryptDecryptService = encryptDecryptHelper.buildEncryptDecryptServiceImpl();
try {
encryptDecryptService.setValue(encIds.get("schoolId").toString(), encIds.get("classId"), SupportedEncryption.AES256);
return encryptDecryptService;
} catch (InvalidPropertiesFormatException | RuntimeException e) {
try {
encryptDecryptService.setValue("0", 0, SupportedEncryption.AES256);
return encryptDecryptService;
} catch (InvalidPropertiesFormatException ex) {
throw new RuntimeException(ex);
}
}
}
}
< /code>
Этот класс расширяется в нескольких других классах, где мы делаем записи зашифрованные или расшифрованные < /p>
@Slf4j
@Component
public class OptStudentEventListener extends StudentEventListener {
@PrePersist
public void encryptRecord(OptStudent os) throws Throwable {
if (os.getIsEncrypted()) {
return;
}
EncryptDecryptService encryptDecryptService = determineEncryptionKey(os);
os.setFirstName(encryptDecryptService.encryptString(pc.getFirstName()));
os.setLastName(encryptDecryptService.encryptString(pc.getLastName()));
os.setMiddleName(encryptDecryptService.encryptString(pc.getMiddleName()));
os.setIsEncrypted(true);
}
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... emove-this