반응형

분류 전체보기 130

[Java] POI 라이브러리 엑셀 다운로드

1. 라이브러리를 추가한다. 2. VO를 생성해준다. - 엑셀 파일: ExcelVO public class ExcelVO { private String fileName;//엑셀 파일명 private Stirng sheetName;//시트명 private int freezePaneCol;//고정col private int freezePaneRow;//고정row private DataVO dataVO;//데이터의 VO final List cellVOList=new ArrayList();//셀을 담은 List; } - 엑셀을 이루는 Cell: CellVO public class CellVO { private String field;//VO의 필드값을 넣어줌 private String header;//엑셀의 첫..

Java 2022.05.18

@Controller 와 @RestContoller (@ResponseBody)

@Controller란? 일반적으로 @Controller에서는 클라이언트의 요청을 컨트롤러가 처리한 후 View 이름을 반환한다. View Resolver가 View 이름으로 해당 View를 찾아 클라이언트에게 보여준다. 만약, @Controller에서 객체를 반환하려면? @ResponseBody 를 붙여주면 해당하는 Mapping은 View 이름이 아닌 객체를 Json 형태로 반환해준다. 이때, 일반적으로 ResponseEntiry 형태로 반환해주게 된다. @RestContoller란? @Controller + @ResponseBody 를 의미한다. @RestController에서는 View를 반환하는 것이 아니라, 객체를 Json 형태로 반환하기 때문에 View Resolver가 아닌 HttpMess..

스프링 2022.04.12

System.getProperty() 란?

Java에서 코드 작성 시 운영체제 정보나 현재 파일의 위치 등이 필요할 때 사용한다. System.getProperty() 안에 검색어를 입력하면 그 값이 String 타입으로 반환된다. ex) // 현재 디렉토리 위치 반환 String currentDir = System.getProperty("user.dir"); 첨부파일 업로드/다운로드 시 경로 설정에 사용할 수 있음 ()안에 들어갈 검색어로는 java.version , java.vendor , java.home , java.class.path , os.name , os.version , user.name , user.home , user.dir ...

Java 2022.03.30

[git] git statsh

내 로컬 저장소에서 코드를 수정 중인데 원격 저장소에 새로운 commit이 발생한 경우 pull을 하면 파일이 충돌하는 경우가 생긴다. 이때, 수정 중인 코드를 commit 할 수 없기 때문에 사용하는 것이 git stash 명령어이다. 이 명령어는 말그대로 commit 되지 않은 변경사항이 있는 파일들을 임시로 숨겨준다. git stash 하면 워킹 디렉토리가 HEAD 상태로 만들어준다. 그 후 git pull 로 당겨온다. - stash 의 임시 저장된 파일들 워킹 디렉토리에 적용 & statsh 에서 제거 git stash pop

git 2022.03.30

[Java] Java8 Stream 사용법

1. 생성 List list = Arrays.asList("a", "b", "c"); //방법1 Arrays.stream(list); //방법2 list.stream(); //방법3 Stream.of("a", "b", "c"); 2. 반환타입 - 중간연산 : return Stream; filter(), map(), flatmap(), distinct(), sort(), peek(), limit(), skip() .. - 최종연산 : return 특정한 type 3. collect collect()를 구현한 collectors의 정적 메서드 - toList(), toSet(), toCollection(), toMap() list.stream().collect(Collectors.toList()); list..

Java 2022.03.29

[Spring] 스프링부트 스케줄러 사용하기

1. @SpringBootApplication 이 선언된 패키지에 @EnableScheduling 애노테이션을 선언한다. * @EnableScheduling 은 @SpringBootApplication 이 선언된 패키지 또는 하위 패키지에 붙여야 함. @SpringBootApplication @EnableScheduling public class SchedulerApplication{ public static void main(String[] args){ SpringApplication.run(SchedulerApplication.class, args); } } 2. 스케줄러를 구현할 class에 @Component 애노테이션을 선언한다. 3. 스케줄러가 되는 메서드에 @Scheduled 애노테이션을 선..

스프링 2022.03.29

[Spring] application.properties 또는 application.yml 파일에 미리 값을 지정해둔 다음 사용하기

- application.yml ( application.properties ) 파일 my-host-id: xxx.xxx.xxxx schedule: /* 10분 간격으로 03분, 13분, 23분, 33분, 43분, 53분 실행 */ TestBatch: 0 3/10 * * * * ----------------------------------------------------------------- my-host-id=xxx.xxx.xxxx schedule.TestBatch=0 3/10 * * * * - 속성 값을 사용하는 class @Slf4j @RequiredArgsConstructor @Component public class TestBatch{ @Value("${my-host-id}") private ..

스프링 2022.03.29
반응형