哪里调用EntityResource构造函数?

时间:2019-01-08 13:15:12

标签: java rest model-view-controller jhipster

我有两个实体的jHipster项目-用户和客户端。客户具有“ user_id”字段,该字段保留创建了客户实体的那个用户的user_id。

ClientResource.java

@RestController
@RequestMapping("/api")
public class ClientResource {

    private static final String ENTITY_NAME = "client";
    private final Logger log = LoggerFactory.getLogger(ClientResource.class);
    private final ClientService clientService;

    private final UserService userService;

    private final ClientQueryService clientQueryService;

    public ClientResource(ClientService clientService, ClientQueryService clientQueryService, UserService userService) {
        this.clientService = clientService;
        this.clientQueryService = clientQueryService;
        this.userService = userService;
     }

....................

@PostMapping("/clients")
@Timed
public ResponseEntity<ClientDTO> createClient(@RequestBody ClientDTO clientDTO) throws URISyntaxException {
    log.debug("REST request to save Client : {}", clientDTO);
    if (clientDTO.getId() != null) {
        throw new BadRequestAlertException("A new client cannot already have an ID", ENTITY_NAME, "idexists");
    }

    String login = SecurityUtils.getCurrentUserLogin().toString();
    Long loggedUserId = userService.getUserWithAuthoritiesByLogin(login).get().getId();

这里我有例外: com.mycompany.hiptest.web.rest.ClientResource.createClient()中的异常,原因为“ NULL”,异常为“无值”

java.util.NoSuchElementException:没有值

我猜是因为我还没有初始化的clientService变量。 但是clientService如何获得价值?我没有找到ClientResource构造函数的任何调用。

0 个答案:

没有答案