개발
-
url 포트번호 없이 사용 (prerouting)개발/AWS & 서버 2020. 4. 17. 13:22
예를 들어 IP가 15.164.0.12 인 ec2 서버에 포트번호가 8080인 was를 올렸을 때 was를 호출하기 위해선 15.164.0.12:8080 과 같이 포트번호까지 필요하다. 15.164.0.12를 abc.com dns을 등록하여 사용한다면 abc.com:8080과 같이 호출하여야 한다. 도메인만으로 호출하고 싶을땐 기본포트를 해당 8080으로 리다이렉트해야한다. 현재적용상태 확인 sudo iptables -t nat -L 리다이렉트(80 -> 8080) sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 초기화 sudo iptables -F -t nat 해당인스턴스 보안그룹 인바운드 규칙에 http ..
-
AWS 배포환경에서 OOME 발생시개발/AWS & 서버 2020. 4. 16. 11:32
aws elasticbeanstalk에 올린 spring boot 스케쥴링이 실행되지 않았다. 로그를 확인해 보니 java.lang.OutOfMemoryError: Java heap space t2.micro 환경에서 대량의 데이터를 저장하는데 @transactional을 걸어두다보니 생긴일이다. t2.micro의 메모리는 1G transaction으로 처리되어 저장되는 데이터가 많다 했는데 결국 OOME가 발생하였다. 현재는 얼마였고, 어느정도까지 늘리면 될까?? 리눅스 환경에서 JVM의 힙메모리가 궁금해졌다. JAVA default Heap size는 다음과 같은 명령어로 확인이 가능하다. [Linux] java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E '..
-
jpa entity 기본 생성자(Default Constructor) 필요할때개발/Spring 2020. 3. 10. 10:43
jpa로 검색해오는 소스에서 기본 생성자 관련 에러가 발생했다. 검색과 고민 끝애 해당 객체의 이름만 딴 기본생성자를 넣었고, 문제 없이 조회가 가능해졌다 @Entity public class Student{ protected String name; protected int age; public Student(Graduate graduate) this.name = graduate.getName(); this.age = graduate.getAge(); } 와같이 student를 저장할때 졸업생으로 받았다면 학생으로 생성후 저장하려고 생성자를 만들어 뒀는데 이로인한 기본 생성자 에러가 발생한 것이다. JPA는 조회시 default Constructor로 객체를 생성한 뒤 Reflection을 이용해 값을 ..
-
webclinet 응답 객체 다루기 (json 객체)개발/Spring 2020. 3. 6. 18:46
webclinet 응답 데이터를 vo 객체나 string 탑이로 받는것은 보이는데 json은 없다. vo 형태로 받기에 있을법도 한데 없어서 한참을 검색하고, 레퍼런스를 봤지만 찾을수가 없었다. 택한 방법은 string으로 받은 후 json으로 변경하였다. Mono result = getClient.get ( ) .uri (uri) .retrieve ( ).bodyToMono (String.class).map (s -> { // ObjectMapper mapper = new ObjectMapper ( ); try { JsonNode jsonNode = mapper.readTree (s); return jsonNode; } catch (JsonProcessingException e) { e.printSta..
-
Webclinet 응답 메모리 늘리기개발/Spring 2020. 3. 6. 18:31
webclient으로 api서버로 부터 데이터를 회신하는데 많을때는 약 5mb정도의 json 데이터가 오기때문에 메모리 제한 에러가 발생한다. 이럴때 webclient 생성시 설정을 다음과 같이 하면된다 WebClient webClient = WebClient.builder() .exchangeStrategies(builder -> builder.codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(2 * 1024 * 1024) ) ) .build(); 설명에 따르면 default로 256kb로 설정되어져 있다. 참고 https://docs.spring.io/spring/docs/current/spring-framework-reference/web-react..
-
double 형 비교개발/JAVA 2020. 3. 3. 17:34
값 비교에서 string은 equals() 함수를 잘 활용하지면 숫자값은 주로 == 연산자로 값 비교를 해왔다. 그러던 중 똑같은 double형 값을 비교했는데 == 연산자로 확인이 되지 않았다. @Test public void compareNumber(){ List aList = new ArrayList (); double a = 10.0; aList.add (a); List bList = new ArrayList (); double b = 10; bList.add (b); System.out.println (a==b ); System.out.println (aList.get (0)==bList.get (0) ); } 위 처럼 double a와 b 를 연산자로 비교하였을때 true지만
-
docker - spring boot 스프링 부트 프로젝트 도커에 올리기 1개발/Docker 2020. 2. 21. 17:41
참조 :스프링 부트 도커 가이드 https://spring.io/guides/gs/spring-boot-docker/ 1.spring boot 프로젝트 내 DockerFIle 생성 FROM openjdk:8-jdk-alpine LABEL maintainer="developer@gmail.com" VOLUME /tmp ARG JAR_FILE=build/libs/*.jar COPY ${JAR_FILE} app.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 2.도커 이미지 빌드 DockerFile이 있는 위치에서 docker build -t dockertest . docker images 이미지가 만들어졌..