본문 바로가기

프로젝트

회사 신규 프로젝트 -1-

회사 신규프로젝트 작업 시작

 

언어: Java17

프레임워크: SpringBoot 3.2.5

DB: mariadb 10.11.7

형상관리: Git Lab

log: log4j2

project: gradle

 

 

SpringBoot 3.2 버전 이상부터는 매개변수를 명시 해주지 않으면 오류가 발생할 수 있다.

java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.

 

 

오류 해결방안으로는 매개변수를 받을 때 value 값을 명시해준다.

//pathVariable로 매개변수를 받을 때 value 값을 명시해줘야 한다.
@RequestMapping(value="/add/{itemType}", method=RequestMethod.POST)
public ResponseEntity<ResponseDTO> add(@Valid @RequestBody ItemDTO itemDTO, @PathVariable("itemType") String itemType){

    ~ 코드내용...

    return ResponseEntity.ok(responseBuilder.build());
}

//ReqpuestParm으로 매개변수를 받을 때 value 값을 명시해줘야 한다.
@RequestMapping(value="/add/{itemType}", method=RequestMethod.GET)
public ResponseEntity<ResponseDTO> add(@RequestParam("name") String value, @PathVariable("itemType") String itemType){

    ~ 코드내용...

    return ResponseEntity.ok(responseBuilder.build());
}