Exception 9

MongoDB 인덱스 안태워질때

실패하던 테스트 Index인데 왜 ....왜지? 했었다. Stack OverFlow 에서도 미리 데이터 들어가 있으면 안됨, @Indexed 가 mongo side 것이 맞나요? 라고 해서 갈피를 못잡던 차.. @Document(collection = "products") @NoArgsConstructor @RequiredArgsConstructor @Getter @Setter public class ProductEntity { @Id private String id; @Version private Integer version; @NonNull @Indexed(unique = true) private int productId; @NonNull private String name; @NonNull priv..

Exception 2021.01.08

@ControllerAdvice 에서 HttpRequest 파라미터를 받지 못합니다.

HttpServletRequest, WebRequest 를 쓰자 .. 에러가 자주 남, o.s.b:spring-boot-starter-web 넣고 HttpServletRequest를 쓰자. @RestControllerAdvice @Slf4j public class GlobalControllerExceptionHandler { @ResponseStatus(NOT_FOUND) @ExceptionHandler(NotFoundException.class) public @ResponseBody HttpErrorInfo handleNotFoundExceptions(HttpServletRequest request, Exception ex) { return createHttpErrorInfo(NOT_FOUND,requ..

Exception 2020.12.16

Eureka Server 관련 ,@SpringBootTest 구동 실패

Eureka Client 의존 추가 시 @SpringBootTest 구동, -> 유레카 서버 안켜져있음! 이라는 메세지가 뜬다. properties 에 eureka.client.enabled=false 걸어서 꺼놓자. @SpringBootTest(properties = "eureka.client.enabled=false",webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class PostRepositoryTest { private static final Logger LOGGER = LoggerFactory.getLogger(PostRepositoryTest.class); @Autowired private PostRepository postRepo..

Exception 2020.12.11

java.lang.IllegalStateException: Cannot call sendError() after the response has been committed

JPA 방향 맵핑 중 Response 보낼 때에 발생. N으로 맵핑되는 필드에 @JsonIgnore . implementation "com.fasterxml.jackson.core:jackson-databind" @Entity public class Account implements Serializable { @Id @GeneratedValue private Long id; private String username; @Transient private String password; private String email; @OneToMany(mappedBy = "account", fetch = FetchType.LAZY ,cascade = CascadeType.ALL) @JsonIgnore private ..

Exception 2020.12.11

java.lang.IllegalArgumentException: No converter found for return value of type

SpringBoot 사용시 ResponseEnitty 를 넘겨줄때 생겨났다. Getter 만들자.. public class Message implements Serializable { private String msg; public String getMsg() { return msg; } public Message(MessageBuilder builder) { this.msg = builder.msg; } public static MessageBuilder builder(){ return new MessageBuilder(); } public static class MessageBuilder { private String msg; private MessageBuilder() {} public Messag..

Exception 2020.12.09

엑셀 파일 로딩시 형변환에러 발생 Safe하게 하기

Cannot get a NUMERIC value from a STRING 엑셀 로딩 작업을 배워보니 이게 Jdbc 드라이버에 리절트 셋이나 프리페어스테이트먼트 쓰는 것과 아주 유사해보인다. 어찌 됬든 에러가났는데, 요렇게 getCellType 으로 상수값과 비교해서 작업하면 Safe 하더라. XSSFCell cell = row.getCell(1); if(null != cell && cell.getCellType() == CellType.STRING) { fruit.setName(cell.getStringCellValue()); }

Exception 2020.10.14

The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

출처는 역시 Stackoverflow. 해당 에러는 말그대로 DispatcherServlet 설정에 컨트롤러를 실행하는 HandlerAdapter..객체가 해당 handler=controller에 필요하다. 라는 이야기 같은데. 대부분 개발자의 @Controller 에노테이션이나, @RequestMapping 경로 설정 실수로 보인다. 마음이 급하던 바보인 내가 무슨 일을 했냐면.. @Controller(value = "/sample/*") @Log4j public class SampleController { @RequestMapping(value = "/file") public void uploadFile(ArrayList files) { files.forEach( f -> { log.info("fil..

Exception 2020.08.09

java.sql.Connection 사용 주의 사항. MySQL Connector/J is closed.

java.sql.SQLException:Connection 1116805717, URL=jdbc:mysql://localhost/h_project serverTimezone=Asia/Seoul, UserName=root@localhost, MySQL Connector/J is closed. 트랜젝션에서 커넥션이 도중에 닫혔거나, 롤백이나, 커밋 스테이트먼트가 로직 상 잘못 설계되었을 때 발생한다. 해당 오류가나면, 메서드의 트랜젝션 범위에서 디버깅을 하며 커넥션이 끊기지는 않는지, 롤백이나 커밋을 할때 문제가 나지는 않는지를 꼭 확인해야한다.

Exception 2020.08.07