skill/Java.Kotlin 18

JPA 에러 JpaSystemException, IdentifierGenerationException

에러 발생 시, org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): … org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): … Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): … JPA @Id가 pk=auto increme..

skill/Java.Kotlin 2024.01.12

springboot @Scheduler 다중 서버에서 한번만 실행 : shedlock

springboot @Scheduler 이용 시, 서버가 여러개 돌아가면 각 서버마다 @Scheduler가 돌아가 중복 처리 됨. Shedlock을 사용하면 스케쥴러가 한 번만 실행 됨. pom.xml 의존성 추가 net.javacrumbs.shedlock shedlock-spring 2.2.0 net.javacrumbs.shedlock shedlock-provider-jdbc-template 2.1.0 config 추가 import net.javacrumbs.shedlock.core.LockProvider; import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; import net.javacrumbs.shedlock..

skill/Java.Kotlin 2023.11.21

[Java] springframework get method request param 배열일 경우, 콤마가 배열로 나눠서 오는 경우 error

import org.springframework.beans.propertyeditors.CustomCollectionEditor; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bin..

skill/Java.Kotlin 2023.10.18

[Swawgger] GetMapping @RequestBody Error

Http Method : Get 으로 설정 후 Request Data를 @RequestBody로 설정하여 Json으로 처리 할 때, @Operation(summary = "목록 조회") @GetMapping (value="/list") public Object list ( @Valid @RequestBody ReqVo req) { ...... Swagger 화면 요청 시, 서버 에러 java.lang.StringIndexOutOfBoundsException: begin -1, end -1, length 329 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319) at java.base/java.lang.String.substring(St..

skill/Java.Kotlin 2023.08.24

[Error] ClassNotFoundException: org.apache.http.impl.client.HttpClients

Springframework 의 RestTemplate 이용 하여, http 통신 구성 시 , public static ResponseEntity send(String url, HttpMethod method, HttpHeaders header, Map params, Class responseType) { HttpComponentsClientHttpRequestFactory httpFactory = new HttpComponentsClientHttpRequestFactory(); httpFactory.setConnectTimeout(5*1000); httpFactory.setReadTimeout(5*1000); RestTemplate restTemplate = new RestTemplate(httpFac..

skill/Java.Kotlin 2023.02.22

Springboot request param VO class로 받을 시, 필수 값 null일 경우 exception handler 처리

Springboot request param VO class로 받을 시, 필수 값 null일 경우 exception handler 처리 RestController @RequestMapping("/test") @RestController public class TestController { @GetMapping(value = "/t1") public Map t1( @Validated ReqVo req) { Request Param VO import lombok.Data; import javax.validation.constraints.NotNull; @Data public class ReqVo{ /** * 필수코드 @NotNull 선언 */ @NotNull String code_type; Exception..

skill/Java.Kotlin 2023.02.01

Springboot @RequestParam null 일 경우, exception handler 처리

springboot restcontroller requestparam 설정 @GetMapping(value = "/test") public Map accounts( @RequestParam(value = "code") String code, @RequestParam(value = "page" , required = false, defaultValue = "0") int page, @RequestParam Map req) throws Exception { @RequestParam 필수값 exception handler 잘못된 예 @ControllerAdvice @RestController public class ResponseExceptionHandler extends ResponseEntityExcept..

skill/Java.Kotlin 2023.01.31