'ITWeb/개발일반'에 해당되는 글 489건

  1. 2019.09.16 [SpringBoot] @PropertySource 로 yaml 파일 읽기
  2. 2019.09.09 [Spring] Could not find method annotationProcessor()..
  3. 2019.09.03 [Javascript] 자동완성 key event 처리
  4. 2019.08.29 [iOS] 앱 내 다중 웹뷰 사용 시 localStorage 등 데이터 공유
  5. 2019.08.29 [IOS] 웹뷰에서 Webkit 사용하기
  6. 2019.08.23 [PUTTY] 다중창 입력 하기
  7. 2019.08.08 [Shell Script] RESTful API Request
  8. 2019.08.08 [개발일반] Terraform 사용 시 에러 발생
  9. 2019.08.05 [개발일반] Ubuntu 사용 시 landscape sysinfo CPU spike 이슈.
  10. 2019.03.19 [Git] git commit 통계 보기

[SpringBoot] @PropertySource 로 yaml 파일 읽기

ITWeb/개발일반 2019. 9. 16. 13:34

아래 문서에 보면 설명이 잘 나와 있습니다.

기록 하는 차원에서 남겨 봅니다.

 

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-yaml-shortcomings

 

24. Externalized Configuration

Getters and setters are usually mandatory, since binding is through standard Java Beans property descriptors, just like in Spring MVC. A setter may be omitted in the following cases:Maps, as long as they are initialized, need a getter but not necessarily a

docs.spring.io

1. If you use “Starters”, SnakeYAML is automatically provided by spring-boot-starter.
2. The YamlPropertySourceLoader class can be used to expose YAML as a PropertySource in the Spring Environment. Doing so lets you use the @Value annotation with placeholders syntax to access YAML properties.

 

SnakeYAML 이 기본 탑재

@Value 로 접근 가능

 

@PropertySource("classpath:/application.yml")
...
@Value("${spring.profiles.active}")
private String profile;

@PropertySource("classpath:/application.yml")
...
@Value("${spring.profiles.active}")
private String profile;

 

:

[Spring] Could not find method annotationProcessor()..

ITWeb/개발일반 2019. 9. 9. 18:23

Intellij 에서 lombok 설정 관련 오류가 난 케이스 입니다.

 

Could not find method annotationProcessor() 이 에러는 gradle 버전 4.6 이상을 사용 하시면 발생 하지 않게 됩니다.

저는 4.4 버전으로 기본 구성을 예전에 해 놓다 보니 이번에 오류가 발생을 했었내요. 

그래서 기록해 둡니다.

 

그 이외는 intellij 설정에서 enable annotation processing 설정을 해주시면 됩니다.

:

[Javascript] 자동완성 key event 처리

ITWeb/개발일반 2019. 9. 3. 08:58

keyUp, keyDown, keyPress, onFocus, onChange 등의 이벤트들이 있습니다.

여기서 한글 처리를 위해서는 keyPress 를 사용 할 수 없는데요.

이유는 keyUp/Down 은 key code 를 리턴 하고, keyPress 는 ascii code 를 리턴 합니다.

이런 이유로 한글에 대한 처리가 되지 않습니다.

 

별거 아닌 내용이지만 또 기억 못할 까봐 기록 합니다.

:

[iOS] 앱 내 다중 웹뷰 사용 시 localStorage 등 데이터 공유

ITWeb/개발일반 2019. 8. 29. 18:05

다중 웹뷰 간 localStorage 에 대한 데이터 동기화 또는 공유가 필요 할 경우 앱 코드 상에서 아래와 같은 식의 선언이 필요 합니다.

 

let uniqueProcessPool = WKProcessPool()

let configA = WKWebViewConfiguration()
configA.processPool = uniqueProcessPool
let webViewA = init(frame: CGRect.zero, configuration: configA)

let configB = WKWebViewConfiguration()
configB.processPool = uniqueProcessPool
let webViewB = init(frame: CGRect.zero, configuration: configB)

이 내용은 저도 공유 받은 내용으로 문제 해결에 도움이 되는 내용이라 기록 차원에서 올려봅니다.

:

[IOS] 웹뷰에서 Webkit 사용하기

ITWeb/개발일반 2019. 8. 29. 09:14

ios app 개발 경험은 없어서 나중에 혹시라도 필요 할까 싶어서 기록해 봅니다.

별거 아니지만 놓치기 쉬운 부분인 것 같내요.

 

우선 app 에서 import WebKit 선언이 되어 있어야 합니다.

그리고 js 에서는 아래와 같이 사용이 되어야 합니다.

try {
    webkit.messageHandlers.FUNCTION_NAME.postMessage(message);
} catch(error) {
    alert(error);
}

여기서 실수 한 부분이 try..catch 절을 사용하지 않고 바로 webkit 을 접근 하면서 undefined 에러가 발생을 했었습니다.

저와 같은 실수는 하지 마세요.

:

[PUTTY] 다중창 입력 하기

ITWeb/개발일반 2019. 8. 23. 10:01

Alt + Command + I

 

현재 열려 있는 탭에서의 모든 패널에 동일한 명령어를 입력 할 수 있습니다.

(이 쉬운걸 매번 기억 못해서 ㅡ.ㅡ;)

 

다시 한번 더 위 명령어를 누르면 토글 됩니다.

:

[Shell Script] RESTful API Request

ITWeb/개발일반 2019. 8. 8. 16:09

가끔 필요 할 때가 있어서 작성해 봅니다.

 

Shell Script)

#!/bin/bash

CURRENT_DATE=$(date '+%Y-%m-%d')
NODES={"localhost:9200" "localhost:9201")
NODE=${NODES[0]}
INDEX="nginx-access-log-$CURRENT_DATE"
REQUEST_JSON_FILE="api-latency-over2sec-dsl.json"

sendMessageToSlack() {
  curl -XPOST -H "Content-Type: application/json; charset=utf-8" 
       -H "Authorization: Bearer xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxx" 
       -d  "{ 'text': '$1'  }"  https://hooks.slack.com/services/xxxxxxxxxxxxxxxx
}

echo "curl --request POST --url http://$NODE/$INDEX/_search --header 'Content-Type: application/json' --data @$REQUEST_JSON_FILE"
RESPONSE_JSON=`curl --request POST --url http://$NODE/$INDEX/_search --header 'Content-Type: application/json' --data @$REQUEST_JSON_FILE`

echo "+++++++++++++++++++++++++++++++++++++++++++++"
echo $RESPONSE_JSON | jq .aggregations.long_latency.buckets[0].doc_count
echo "+++++++++++++++++++++++++++++++++++++++++++++"

INDEX_NAME=$2
ACTION=$3
ALIAS_NAME=$4
TARGET_DATE=$5

RESULT=`curl -s -o /dev/null -w "%{http_code}\n" -XPOST 'http://'$NODE'/_aliases' -H 'Content-Type: application/json' -d '
{
  "actions" : [
      { "'$ACTION'" : { "index" : "'$INDEX_NAME'-'$TARGET_DATE'", "alias" : "'$INDEX_NAME'-'$ALIAS_NAME'" }}
  ]
}'`

api-latency-over2sec-dsl.json)

{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "response_time": {
                  "gte": "2"
                }
              }
            },
            {
              "range": {
                "@timestamp": {
                  "gte": "now-1h",
                  "lt": "now"
                }
              }
            }
          ]
        }
      }
    }
  },
  "size": 0,
  "aggs": {
    "long_latency": {
      "date_histogram": {
        "field": "@timestamp",
        "interval": "1h",
        "time_zone": "+09:00",
        "order" : { "_key" : "desc" }
      }
    }
  }
}
:

[개발일반] Terraform 사용 시 에러 발생

ITWeb/개발일반 2019. 8. 8. 09:17

아래 에러 메시지가 나오면 테라폼의 버전을 확인해 보라고 합니다.

뭐 에러 메시지에 이미 직관적으로 나와 있긴 하니까 쉽게 확인 가능 하실 듯 하내요.

 

$ terraform -v

 

에러 메시지)

Error refreshing state: state snapshot was created by Terraform v0.12.5, which is newer than current v0.12.0; upgrade to Terraform v0.12.5 or greater to work with this state

:

[개발일반] Ubuntu 사용 시 landscape sysinfo CPU spike 이슈.

ITWeb/개발일반 2019. 8. 5. 13:23

제목 그대로 입니다.

관련 현상을 경험 해서 일단 기록합니다.

 

사용 중인 ubuntu version)

18.04

 

CPU overconsumption)

15~ 40% 수준

 

사용 환경)

AWS

 

일단 해당 기능에 대해서 ssh tunneling 시 발생 할 수 있기 때문에 disable 후 문제는 일단 해소 되었습니다.

다만, 이로 인해 문제가 된 것인지는 정확 하지 않습니다.

재 설정 시 동일 문제가 발생 하지 않았기 때문 이고요, 그 이외 어떤 변경 작업도 진행 하지 않았습니다.

:

[Git] git commit 통계 보기

ITWeb/개발일반 2019. 3. 19. 11:27

파일명 마음에 안들지만 그냥 귀찮으니 그대로 올립니다.


$ tree -f

.

├── ./git-stats-period.sh

├── ./git-stats.sh

└── ./project_clone.sh


$ ./git-stats-period.sh 1 git-stats


git-stats-period.sh) 통계 추출 메인 스크립트

#!/bin/bash


PERIOD=$1

CLONE_DIR=$2


if [ "$#" -ne 2 ]

then

echo "example $ ./git-stats-period.sh PERIOD CLONE-DIR"

echo "example $ ./git-stats-period.sh 7 git-temp"

exit 0

fi


mkdir -p $CLONE_DIR


./project_clone.sh $CLONE_DIR


cd $CLONE_DIR

rm -f ./git-stats-temp.log

rm -f ./git-committers.log


for (( idx=1; idx<=$PERIOD; idx++ ))

do

# 디렉토리 목록을 가져오고, all.log 파일은 삭제

for dir in $(ls -d */)

do

echo ${dir%%/}

echo "rm -f ./${dir%%/}/git-stats-all.log"

echo "../git-stats.sh $idx ${dir%%/}"

rm -f ./${dir%%/}/git-stats-all.log

../git-stats.sh $idx ${dir%%/}

done

done


sort ./git-committers.log | uniq > ./git-uniq-committers.log



git-stats.sh) 통계 추출 실행 스크립트

#!/usr/bin/env bash


pwd

cd $2


#git stash

#git pull

#exit 0


DAYS_AGO=$1

DATE=`date -v -"$DAYS_AGO"d +%F`

PWD=`pwd`


rm -f ./git-stats-$DATE.log

echo "Date : $DATE" > "git-stats-$DATE.log"

echo "Date : $DATE" >> "git-stats-all.log"

echo "Date : $DATE" >> "../git-stats-temp.log"

# This script must exist under git repository.


echo "[Commit Statistics]" >> "git-stats-$DATE.log"

echo "[Commit Statistics]" >> "git-stats-all.log"

echo "[Commit Statistics]" >> "../git-stats-temp.log"

# total commit stats

USER_COUNT=`git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u | wc -l`

echo "Total Commit Users : $USER_COUNT" >> "git-stats-$DATE.log"

echo "Total Commit Users : $USER_COUNT" >> "git-stats-all.log"

echo "Total Commit Users : $USER_COUNT" >> "../git-stats-temp.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-$DATE.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-all.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "../git-stats-temp.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"

echo "" >> "../git-stats-temp.log"


echo "[Committers]" >> "git-stats-$DATE.log"

echo "[Committers]" >> "git-stats-all.log"

echo "[Committers]" >> "../git-stats-temp.log"

# commit user list

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-all.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "../git-committers.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "../git-stats-temp.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"

echo "" >> "../git-stats-temp.log"


echo "[Commit Logs]" >> "git-stats-$DATE.log"

echo "[Commit Logs]" >> "git-stats-all.log"

echo "[Commit Logs]" >> "../git-stats-temp.log"

# each user commit stats

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-all.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "../git-stats-temp.log"



project_clone.sh) git repo clone 스크립트

#!/bin/bash

CLONE_DIR=$1

echo "현재 받아 놓은 Repository는 모두 삭제 됩니다. 진행 하시겠습니까? (y/n)"
read answer

cd $CLONE_DIR

if [ "$answer" == "y" ]; then
  rm -rf *
else
  exit 0
fi

arr_repos=("GIT-REPOSITORY[http://...]")

for git_repo in "${arr_repos[@]}"; do
  if [ "$answer" == "y" ]; then
    git clone $git_repo
    echo ""
  fi
done



: