'ITWeb'에 해당되는 글 798건

  1. 2021.10.05 [Logback] JSON Layout Format 적용하기.
  2. 2021.09.30 [ngrinder] groovy script 작성 참고 문서.
  3. 2021.09.27 [SpringBoot] Application 실행 시 특정 작업 실행 시키기
  4. 2021.09.16 [SpringBoot] 깡통 프로젝트 생성 후 실행 시 에러 (Error creating bean with name 'dataSource' defined in class path resource)
  5. 2021.09.15 [Gradle] 6.x 에서 7.x 로 넘어 오면서 runtime, compile.
  6. 2021.09.14 [Java] List 중복 제거.
  7. 2021.09.07 [ZSH] oh-my-zsh 설정 on Macbook.
  8. 2021.09.06 [wget] proxy 설정 사용.
  9. 2021.08.30 [NLP] 자연어 처리 문서 링크
  10. 2021.08.19 [Architecture] Microservices Pattern.

[Logback] JSON Layout Format 적용하기.

ITWeb/개발일반 2021. 10. 5. 18:52

Springboot 로 프로젝트 생성 후 로깅 하면서 로그 포멧을 JSON 으로 적용 하기 위한 내용을 기억 차원에서 작성 합니다.

 

[logback.xml]

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
        <timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
        <timestampFormatTimezoneId>Asia/Seoul</timestampFormatTimezoneId>
        <appendLineSeparator>true</appendLineSeparator>
        <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
          <prettyPrint>true</prettyPrint>
        </jsonFormatter>
      </layout>
    </encoder>
  </appender>

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>application/application.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>application/application-%d{yyyy-MM-dd}.log</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>

    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
        <timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
        <timestampFormatTimezoneId>Asia/Seoul</timestampFormatTimezoneId>
        <appendLineSeparator>true</appendLineSeparator>
        <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
          <prettyPrint>true</prettyPrint>
        </jsonFormatter>
      </layout>
    </encoder>
  </appender>

  <logger name="org.springframework" level="error" additivity="false" />
  <logger name="org.apache" level="error" additivity="false" />
  <logger name="com.zaxxer" level="error" additivity="false" />
  <logger name="io.netty" level="error" additivity="false" />
  <logger name="reactor" level="error" additivity="false" />
  <logger name="com.xxxxx" level="debug" additivity="false">
    <appender-ref ref="FILE" />
  </logger>

  <root level="debug">
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="FILE"/>
  </root>
</configuration>

 

[build.gradle]

compile "ch.qos.logback.contrib:logback-jackson:${props.getProperty('logback-jackson')}"
compile "ch.qos.logback.contrib:logback-json-classic:${props.getProperty('logback-json-classic')}"

- 여기서 사용 버전은 0.1.5 입니다.

 

사용한 timezone 은 ETC/UTC 가 아닌 Asia/Seoul 로 설정 했습니다.

:

[ngrinder] groovy script 작성 참고 문서.

ITWeb/개발일반 2021. 9. 30. 12:43

https://github.com/naver/ngrinder/wiki/Groovy-Script-Structure

참고해서 작성 하면 되겠습니다.

 

http://naver.github.io/ngrinder/

 

 

 

:

[SpringBoot] Application 실행 시 특정 작업 실행 시키기

ITWeb/개발일반 2021. 9. 27. 12:39

아래 세 가지 방법으로 실행 시킬 수 있습니다.

@Component
public class RunAfterApplicationStart implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) {
        // 실행 코드
    }
}

@Component
public class RunAfterApplicationStart implements CommandLineRunner {

    @Override
    public void run(String... args) {
        // 실행 코드
    }
}

@Component
public class RunAfterApplicationStart {

    @EventListener(ApplicationReadyEvent.class)
    public void hello() {
        // 실행 코드
    }
}

 

:

[SpringBoot] 깡통 프로젝트 생성 후 실행 시 에러 (Error creating bean with name 'dataSource' defined in class path resource)

ITWeb/개발일반 2021. 9. 16. 17:26

springboot 프로젝트 만들어야 할 때 이용 합니다.

https://start.spring.io/

필요한 dependency 추가해 주고 로컬로 다운로드 받아 바로 실행 시켜 봅니다.

근데 깡통임에도 불구하고 에러가 발생을 했습니다.

 

mybatis 를 추가 했을 경우 application.yml 에 datasource 관련 설정을 하지 않게 되면 발생 하는 에러 입니다.

아래와 같이 설정을 추가 하고 build.gradle 에 mysql connector lib 도 추가해 주고 실행 하면 에러가 없어 집니다.

 

[error logs]
2021-09-16 17:24:18.201  WARN 76669 --- [  restartedMain] ConfigServletWebServerApplicationContext : 
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: 
Factory method 'dataSource' threw exception; 
nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: 
Failed to determine a suitable driver class
2021-09-16 17:24:18.205  INFO 76669 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

[application.yml]
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/...
    username: ${USER}
    password: ${PASSWORD}
    
[build.gradle]
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.26'

 

:

[Gradle] 6.x 에서 7.x 로 넘어 오면서 runtime, compile.

ITWeb/개발일반 2021. 9. 15. 17:51

아래와 같이 변경 해서 사용 하면 됩니다.

- Gradle 6.x 에서 Gradle 7.x 로 넘어 오면서 runtime, compile.
[6.x]
task copyDependencies(type: Copy) {
  into "$buildDir/libs/deps"
  from configurations.runtime
}

[7.x]
task copyDependencies(type: Copy) {
  into "$buildDir/libs/deps"
  from configurations.runtimeClasspath
}

[6.x]
jar {
  manifest {
    attributes 'Main-Class': 'Main.class',
        'Class-Path': configurations.compile.files.collect { "deps/$it.name" }.join(' ')
  }

  archiveName 'dictionary.jar'
  from {
    configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

[7.x]
jar {
  manifest {
    attributes 'Main-Class': 'Main.class',
        'Class-Path': configurations.compileClasspath.files.collect { "deps/$it.name" }.join(' ')
  }

  archiveName 'dictionary.jar'
}

 

:

[Java] List 중복 제거.

ITWeb/개발일반 2021. 9. 14. 12:34

DictionaryModel 은 String, List<String> 맴버 변수를 가집니다.

이 맴버 변수 중 List<String> 을 모두 펼쳐서 distinct word 목록을 만들려고 합니다.

 

List<String> flats = new ArrayList<>();
List<String> words = new ArrayList<>();

for (DictionaryModel d : dictionarys ) {
	words.addAll(d.getAnalyzed());
}

flats = words.stream().distinct().collect(Collectors.toList());

기억력을 돕기 위해 기록해 봅니다.

 

:

[ZSH] oh-my-zsh 설정 on Macbook.

ITWeb/개발일반 2021. 9. 7. 10:47

또 뭔가 찾기 귀찮아서 기록해 봅니다.

 

[oh-my-zsh 설치]
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

 

[iTerm2 Color Schemes]
https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/schemes

 

[d2font 설치] (서체관리자 추가 및 iTerm 추가)
https://github.com/naver/d2codingfont

 

[highlighting]
$ brew install zsh-syntax-highlighting

$ vi .zshrc 하단에 추가
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

 

[Insecure Directory Skip]

$ vi .zshrc 제일 윗줄에 추가

 ZSH_DISABLE_COMPFIX=true

 

[Theme 수정]

$ vi .zshrc 수정 및 추가

ZSH_THEME="agnoster"
...중략...
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]];
  then
  	prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
  fi
}

 

[newline 추가]

$ vi ~/.oh-my-zsh/themes/agnoster.zsh-theme

build_prompt() {
  RETVAL=$?
  prompt_status
  prompt_virtualenv
  prompt_aws
  prompt_context
  prompt_dir
  prompt_git
  prompt_bzr
  prompt_hg
  prompt_newline # <-- 추가
  prompt_end
}

 

[newline & multiline 적용]

PROMPT='%{%f%b%k%}$(build_prompt) '

# 아래 6, 7번 라인은 아래와 같이 작성을 하셔야 정상적으로 나옵니다.
prompt_newline() {
  if [[ -n $CURRENT_BG ]]; then
    echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR
%{%k%F{blue}%}$SEGMENT_SEPARATOR"
  else
    echo -n "%{%k%}"
  fi

  echo -n "%{%f%}"
  CURRENT_BG=''
}

 

[plugin 적용]

- zsh-syntax-highlighting

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

 

- zsh-autosuggestions

$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

 

$ vi .zshrc

plugins=(
  git
  zsh-syntax-highlighting
  zsh-autosuggestions
  web-search
  jsontools
  macports
  node
  osx
  sudo
  docker
  iterm2
)
:

[wget] proxy 설정 사용.

ITWeb/개발일반 2021. 9. 6. 20:11

Proxy 사용 시 wget 에서도 설정을 해 줄 수 있습니다.

아래와 같이 사용 하시면 됩니다.

 

[general]

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-darwin-x86_64.tar.gz

 

[http]

$ wget -e use_proxy=yes -e http_proxy=proxy.abcdefg.com:8080 http://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-darwin-x86_64.tar.gz

 

[https]

$ wget -e use_proxy=yes -e https_proxy=proxy.abcdefg.com:8080 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-darwin-x86_64.tar.gz

:

[NLP] 자연어 처리 문서 링크

ITWeb/스크랩 2021. 8. 30. 11:59

책을 출간 하기 위해 작성 하고 계시는 것 같습니다.

그래서 링크만 걸어 봅니다. ^^

 

딥 러닝을 이용한 자연어 처리 입문 : https://wikidocs.net/book/2155
동일 저자가 만든 PyTorch 학습 자료 : https://wikidocs.net/book/2788
이 책을 위해 제작한 이미지 자료 공유 (영리적 목적 제외 자유롭게 사용) : https://www.slideshare.net/wonjoonyoo/ss-188835227
딥 러닝 추천 자료 : https://www.d2l.ai/index.html
NLP 참고 자료 : http://www.phontron.com/class/nn4nlp2019/schedule.html, https://github.com/makcedward/nlp
한국어 NLP 논문 모음 : https://github.com/papower1/Awesome-Korean-NLP-Papers

:

[Architecture] Microservices Pattern.

ITWeb/스크랩 2021. 8. 19. 10:35

https://microservices.io/patterns/index.html

 

Microservices Pattern: A pattern language for microservices

Microservices.io is brought to you by Chris Richardson. Experienced software architect, author of POJOs in Action, the creator of the original CloudFoundry.com, and the author of Microservices patterns. Chris helps clients around the world adopt the micros

microservices.io

 

: