[英]Consider defining a bean of type 'form' in your configuration
Place that is complaining the error:抱怨错误的地方:
@Data
public class AluguelValorForm {
@Autowired
private ValorAluguelMultaService valorAluguelMultaService;
@NotNull @NotEmpty
private String idAluguel;
@NotNull
private Double valor;
public AluguelValor converter(AluguelValorRepository aluguelValorRepository, AluguelForm form ) {
Double valorAluguel = valorAluguelMultaService.valorAluguel(form);
return new AluguelValor(idAluguel,valorAluguel);
}
public AluguelValor update(String idAluguel,Double valor) {
AluguelValor aluguelValor = new AluguelValor();
aluguelValor.setId(idAluguel);
aluguelValor.setValor(valor);
return aluguelValor;
}
Repository:存储库:
@Repository
public interface AluguelValorRepository extends MongoRepository<AluguelValor, String> {
Aluguel getReferenceById(String id);
}
Place that I call the method in AluguelValorForm:我在 AluuelValorForm 中调用方法的地方:
@PostMapping
//@CacheEvict(value = "listaDeTopicos",allEntries = true)
public void cadastrar(@RequestBody AluguelForm form) {
Optional<Carro> carro = carroRepository.findByPlaca(form.getPlaca_carro());
Optional<Cliente> cliente = clienteRepository.findByCpf(form.getCpf());
if(carro.isPresent() && cliente.isPresent()) {
Aluguel aluguel2 = form.converter(aluguelRepository);
aluguelRepository.save(aluguel2);
Double valorAluguel = valorAluguelMultaService.valorAluguel(form);
AluguelValor aluguelValor = aluguelValorForm.update(aluguel2.getId(), valorAluguel);
aluguelValorRepository.save(aluguelValor);
}
}
Problem solved.问题解决了。 Apparently, it's not possible to @Autowired a class that doesn't have any bean, like my RentValue.
显然,不可能@Autowired 没有任何 bean 的 class,比如我的 RentValue。 That's why I got this error.
这就是我收到此错误的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.