요즘 프로젝트 리팩토링을 하고 있습니다. 엑셀 관련 된 부분이 엉망인데 그 엉망인 코드를 복사해서 여기 저기 쓰고 있었습니다. 깔끔한 소스, 중복제거, 재사용 가능할 것을 목표로 만들었습니다. 1. 요구사항 프로젝트의 "/src/main/resources/static/format" 디렉토리 아래 "testExcel.xlsm"를 읽는다. 해당 엑셀의 3번째 시트의 데이터를 가져온다. 해당 엑셀의 시트명("Sheet3")으로 데이터를 가져온다.데이터는 List에 자료구조(Map)으로 반환한다. 데이터는 List에 객체로 반환한다. 헤더를 정의해서 가져온다. 엑셀의 첫번째 Row를 헤더로 사용하는 경우도 있다. 원하는 데이터를 스킵할 수 있어야 한다. 2. Gradle Dependencies compile (..
예전에 자주 사용하던 걸을 자꾸 잊게 됩니다. 토비님 글 보고 쓰던건데 아주 유용합니다. Eclipse - window - Preference - Java - Editor - Templates [New] 추가 자신이 원하는 이름으로 만들면 됩니다. 내용import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import static org.junit.matchers.JUnitMatchers.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; 이클립스에서 test 해보시면 됩니다. 자동 생성 후 Organize Imports (Ctrl+Sh..
Colorscripter 코드 작성할 때 유용https://colorscripter.com/ Spring 레퍼런스https://spring.io/docs/reference Spring Boothttp://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference Spring Boot Sample GitHubhttps://github.com/spring-projects/spring-boot.git Spring JPA referencehttps://docs.spring.io/spring-data/jpa/docs/current/reference Spring securityhttp://docs.spring.io/spring-security/site/docs/4.2...
Remove this "BigDecimal" constructor수정 전 public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (null == value) { jgen.writeNull(); } else { jgen.writeNumber(new BigDecimal(value).setScale(2, BigDecimal.ROUND_DOWN)); } }수정 후 public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (null == v..
Use "java.nio.Files#delete" here for better messages on error conditions.SonarQube를 이용하니 새로운 기술도 알려 주네요. ^^수정 전public static boolean deleteFile(String path, String name){ File file = new File(path + name);if(file.exists()){return file.delete();}return false;}수정 후 public static boolean deleteFile(String path, String name) { Path filePath = FileSystems.getDefault().getPath(path, name); try { Files..
"Add a private constructor to hide the implicit public one."유틸 클래스에서는 public 생성자가 없어야 합니다. 유틸 클래스 만들 때는 private 생성자를 추가해 주세요. public class ValidatorUtil { private ValidatorUtil() { throw new IllegalStateException("Utility class"); }...} Utility classes should not have public constructors (squid:S1118) Code smell MajorUtility classes, which are collections of static members, are not meant to be i..
Combine this catch with the one at line 82, which has the same body. 동일 처리를 하는 catch문 합치기 수정 전public boolean checkUser(UserParam userParam) {try {if(getUserInfo(userParam) != null) return true;}catch(DataNotFoundException e) {return false;}catch(UserNotFoundException e) {return false;}return false;}수정 후public boolean checkUser(UserParam userParam) {try {if(getUserInfo(userParam) != null) return ..
Iterate over the "entrySet" instead of the "keySet". Map에 있는 키 값을 꺼내서 루프를 돌리는데 만약 key값 이외 value도 필요하다며 keySet을 사용하지 말고 entrySet을 사용하라. "entrySet()" should be iterated when both the key and value are needed (squid:S2864) Code smell Major When only the keys from a map are needed in a loop, iterating the keySet makes sense. But when both the key and the value are needed, it's more efficient to iter..
Object를 일반적인 방법으로 복제를 하는 경우 문제가 발생할 수 있습니다. 아래 예제를 통해 확인해 보겠습니다. 테스트 코드 public class TestClone { public static void main(String[] args) { User user1 = new User("test1"); User cUser1 = (User)user1.clone(); cUser1.setName("test2"); System.out.println(user1.toString()); System.out.println(cUser1.toString()); } public static class User implements Cloneable, Serializable{ private String name; private..
- Total
- Today
- Yesterday
- ag grid
- 예제
- REST
- lombok
- mapToList
- 엑셀
- 메시지
- oracle
- cache
- thymeleaf
- 스프링
- UI
- Javascript
- sample
- SHEETJS
- Spring Boot
- listToMap
- java
- restful서비스
- 스프링부트
- AG-GRID
- spring
- RESTful
- 타임리프
- springboot
- 그리드
- example
- mybatis
- 설정
- 샘플
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |