💻IT 19

[Java] Java 8 Stream API

참고 https://www.baeldung.com/java-8-streams-introduction https://www.baeldung.com/java-8-streams Stream API란? JAVA8의 새로운 기능 Stream 기능에는 시퀀셜한 데이터를 처리하는 클래스들이 포함되어있음 Stream 생성 collection이나 array의 stream() Stream의 of() String[] arr = new String[]{"a", "b", "c"}; Stream stream = Arrays.stream(arr); stream = Stream.of("a", "b", "c"); Empty Stream Stream.empy()로 element가 없는 stream을 생성할 수 있다. Stream str..

💻IT/Java 2021.12.03

[Spring Boot][Error] Frontend에서 API 호출 시 CORS 문제

문제 Spring Boot 로컬 서버를 8888 포트로 띄워놓고 VueJS Frontend를 8080 포트로 구현 중 API 호출이 CORS 문제를 막히는 문제에 부딪쳤다. 연습 중인지라 이걸 굳이 막을 이유가 없기 때문에 서버단에서 Cross Origin Resource에 대한 요청을 허용하도록 설정을 추가하였다. 해결 서버에 아래 Bean을 등록하여 해결 @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("..

💻IT 2021.11.15

[Java] Deque 자료 구조 (LinkedList 메소드)

Deque 구현체로 ArrayDeque와 LinkedList 를 주로 사용한다. LinkedList에 값을 넣고 뽑기 위한 많은 메소드를 있는데, 헷갈리는 점이 있어서 정리한다. Deque란? 덱(deque, "deck"과 발음이 같음 ← double-ended queue)은 양쪽 끝에서 삽입과 삭제가 모두 가능한 자료 구조의 한 형태이다. 두 개의 포인터를 사용하여, 양쪽에서 삭제와 삽입을 발생시킬 수 있다. 큐와 스택을 합친 형태로 생각할 수 있다. (위키백과, 우리 모두의 백과사전.) 예제1. First에 넣어볼까? LinkedList test = new LinkedList(); test.offerFirst(1); test.offerFirst(2); test.offerFirst(3); System...

💻IT/Java 2021.11.15

[Gradle][Error] compile 사용 시 No candidates found for method call 문제

문제 아래와 같이 compile group 을 추가하려고 하는데, No candidates found for method call 오류가 발생했다. 당연히 reload 시 Exception이 발생한다. Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments 해결 찾아보니 gradle 3.0부터 compile 이 deprecated되었다고 한다. compile을 implementation 으로 변경해서 오류 해결.

💻IT 2021.11.13

[Git] .gitignore 파일이란?

gitignore 이란? 프로젝트 내 다양한 설정 파일, 컴파일된 파일 등 굳이 버전관리가 필요 없는 파일들이 있다. 해당 파일들이 git commit 목록에 계속 보여진다면 불편할 것이다. 이러한 문제를 해결하기 위해, gitignore 파일을 통해 버전관리가 필요없는 파일들을 제외할 수 있다. 프로젝트의 root에 .ignore파일이 위치해야 인식한다. gitignore 작성 방법 제외할 파일의 패턴을 작성한다. https://git-scm.com/docs/gitignore Git - gitignore Documentation The optional configuration variable core.excludesFile indicates a path to a file containing patter..

💻IT 2021.11.02

[IntelliJ][Error] Console 창 한글 깨짐 문제 해결

콘솔에 문자가 깨져서 출력된다. 1. Console Encoding 변경 File > Settings (Ctrl + Alt + S) Editor > General > Console에서 Default Encoding을 UTF-8로 변경해준다. 그래도 문제가 해결 되지 않았다. 2. idea64.exe.vmoptions 파일 수정 shift를 두번 눌러서 'Edit Custom VM Options...'을 Open한다. -Dfile.encoding=UTF-8 추가 후 저장한다. IntelliJ를 재시작 한 후 테스트 해보았다. 문자 깨짐 현상이 해결되었다.

💻IT 2021.10.31

[Java] Convert Array to List / Convert List to Array

Java로 코딩테스트 풀다보면 Array를 List로, List를 Array로 변환할 일이 종종 생깁니다. For문 사용은 제외하고 자주 쓰는 함수 정리합니다. Array를 List로 변환하기 Arrays.asList() 함수를 사용하여 Array를 List로 변환할 수 있습니다. // 1. Convert String[] to List : Arrays.asList(String[]) String[] arr1 = new String[]{"A", "B", "C", "D"}; List list1 = Arrays.asList(arr1); for(String s : list1){ System.out.println(s); } List를 Array로 변환하기 1) List.toArray() 사용 List list3 =..

💻IT/Java 2021.10.18