Hi!
I have this method in my controller that is supposed to create a new entity:
@RestController
@RequestMapping("/settings")
public class SettingController {
private final SettingService settingService;
private final EntitySerializationAPI entitySerializationAPI;
private final MetaClass metaClass;
@Inject
public SettingController(SettingService settingService,
EntitySerializationAPI entitySerializationAPI,
MetaClass metaClass) {
this.settingService = settingService;
this.entitySerializationAPI = entitySerializationAPI;
this.metaClass = metaClass;
}
@PostMapping("/")
public ResponseEntity<String> addSetting(@RequestBody String settingInput,
HttpServletRequest request) {
Setting settingInstance = entitySerializationAPI.entityFromJson(settingInput, metaClass, EntitySerializationOption.PRETTY_PRINT);
Setting setting = settingService.createSetting(settingInstance);
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(request.getRequestURL().toString())
.path("/{id}")
.buildAndExpand(setting.getId().toString());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(uriComponents.toUri());
return new ResponseEntity<>(entitySerializationAPI.toJson(setting), httpHeaders, HttpStatus.CREATED);
}
}
The problem is in this line because the Injection cannot resolve this metaClass bean:
Setting settingInstance = entitySerializationAPI.entityFromJson(settingInput, metaClass, EntitySerializationOption.PRETTY_PRINT);
Error:
Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.haulmont.chile.core.model.MetaClass' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
So how do I convert this JSON from a request into an Entity ?
Thanks in advance!
James