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

  1. 2021.07.27 [OpenJDK] 다운로드 받아서 설치.
  2. 2021.07.27 [Bash] 문자열 비교 예제
  3. 2021.07.19 [HikariCP] Java 버전 호환
  4. 2021.07.15 [JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.
  5. 2021.07.02 [Intellij] intellij-java-google-style.xml 적용하기
  6. 2021.04.19 [Java] jenv 구성
  7. 2021.04.19 [Python] 비동기 요청 예제
  8. 2021.03.03 [Spring] Event Pub/Sub 기능 예제
  9. 2021.02.22 [Spring] 멀티모듈 프로젝트 jar SKIPPED
  10. 2021.02.15 [JQuery] Selectors 링크

[OpenJDK] 다운로드 받아서 설치.

ITWeb/개발일반 2021. 7. 27. 09:46

아래 주소에서 설치할 버전 선택 후 다운로드 받아서 설치 하셔도 됩니다.

 

Early Access

https://download.java.net/java/early_access/jdk18/7/GPL/openjdk-18-ea+7_linux-x64_bin.tar.gz

 

GA

https://jdk.java.net/archive/

 

AdoptOpenJDK

https://adoptopenjdk.net/release_notes.html

https://adoptopenjdk.net/archive.html?variant=openjdk8&jvmVariant=hotspot 

 


                  

:

[Bash] 문자열 비교 예제

ITWeb/개발일반 2021. 7. 27. 08:11
#!/bin/bash

retry='retry'

if [ $retry = "retry" ]; then
  echo 'true - 1'
fi

if [[ $retry = "retry" ]]; then
  echo 'true - 2'
fi

if [[ "$retry" = "retry" ]]; then
  echo 'true - 3'
fi

세 예제 다 true 리턴 합니다.

:

[HikariCP] Java 버전 호환

ITWeb/개발일반 2021. 7. 19. 11:46

빌드 환경과 맞춰서 사용 하셔야 합니다.

안그러면 아래와 같은 에러를 경험 할 수 있습니다.

 

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariConfig has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

 

Artifacts
Java 11+ maven artifact:

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP</artifactId>
   <version>5.0.0</version>
</dependency>
Java 8 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP</artifactId>
   <version>4.0.3</version>
</dependency>
Java 7 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP-java7</artifactId>
   <version>2.4.13</version>
</dependency>
Java 6 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP-java6</artifactId>
   <version>2.3.13</version>
</dependency>

 

:

[JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.

ITWeb/개발일반 2021. 7. 15. 09:42

아래와 같은 에러를 경험 하셨다면 intellij 에서의 설정을 변경해 주시면 됩니다.

 

Execution failed for task ':test'.
> No tests found for given includes: [com.kakaopay.stark.pipeline.indexer.PropertiesTest.testMultilineProperty](filter.includeTestsMatching)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 

IntelliJ -> Preferences -> Build,Execution,Deployment -> Build Tools -> Gradle

Gradle projects -> Run tests using -> Gradle (Default) 를 Intellij IDEA 로 바꾸시면 됩니다.

:

[Intellij] intellij-java-google-style.xml 적용하기

ITWeb/개발일반 2021. 7. 2. 10:10

intellij 버전이 올라 가면서 codestyle 정의가 바뀌었네요.

https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml

이전 글은 import 방법만 참고하시고 새로운 style 을 다운로드 받아서 적용해 보세요.

 


 

각자 필요한 코드 스타일은 아래서 다운로드 받으시면 됩니다.

 

[구글 코드 스타일]

https://github.com/google/styleguide

 

[Intellij 적용하기 - mac]

# 저는 intellij 2016.3 사용중입니다.

# 다운로드 받으신 intellij-java-google-style.xml 파일을 아래 경로로 복사해서 넣습니다.

 

$ cd ~/Library/Preferences/IntelliJIdea2016.3/codestyles

 

[Intellij 에서 import 하기]

Preferences -> Editor -> Code Style -> Manage Button -> Import

 

# 그러나 파일을 먼저 복사해 넣었기 때문에 import 하지 않으셔도 scheme 이 정상적으로 나옵니다.

# Scheme 을 GoogleStyle 로 변경 하시면 끝납니다.

 

:

[Java] jenv 구성

ITWeb/개발일반 2021. 4. 19. 20:13

참고문서)
https://brew.sh/index_ko

 

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install jenv

$ brew tap AdoptOpenJDK/openjdk

 

    # Shell: bash
    echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
    echo 'eval "$(jenv init -)"' >> ~/.bash_profile

    $ source ~/.bash_profile
    
    # Shell: zsh
    echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(jenv init -)"' >> ~/.zshrc

    $ source ~/.zshrc

 

jdk version 별 설치 하기)
$ brew install --cask adoptopenjdk8
$ brew install --cask adoptopenjdk11
$ brew install --cask adoptopenjdk15
$ brew install --cask adoptopenjdk16

 

jenv 추가)
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home

 

jenv 사용)

Usage: jenv <command> [<args>]

Some useful jenv commands are:
   commands    List all available jenv commands
   local       Set or show the local application-specific Java version
   global      Set or show the global Java version
   shell       Set or show the shell-specific Java version
   rehash      Rehash jenv shims (run this after installing executables)
   version     Show the current Java version and its origin
   versions    List all Java versions available to jenv
   which       Display the full path to an executable
   whence      List all Java versions that contain the given executable
   add         Add JDK into jenv. A alias name will be generated by parsing "java -version"

See `jenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/jenv/jenv/blob/master/README.md

 

$ jenv versions

  system
  1.8
* 1.8.0.242 (set by /Users/mzc02-henryjeong/.jenv/version)
  11.0
  11.0.6
  13.0
  13.0.2
  15
  15.0
  15.0.2
  16
  openjdk64-1.8.0.242
  openjdk64-11.0.6
  openjdk64-13.0.2
  openjdk64-15.0.2
  openjdk64-16

JAVA_HOME 변경을 위한 plugin 설치)

$ jenv enable-plugin export

(주의 : eval "$(jenv init -)" 설정이 빠져 있으면 동작 하지 않습니다.)

 

jenv global 설정)

/Users/henryjeong/.jenv/version

 

$ jenv global 11.0
$ jenv global
11.0

 

jenv local 설정)

$ jenv local 16
$ jenv local
16
$ java -version
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)

 

로컬 설정은 해당 버전이 필요한 Application 에 들어가서 실행 하시면 됩니다.

:

[Python] 비동기 요청 예제

ITWeb/개발일반 2021. 4. 19. 18:47

비동기 처리 하는거 예제가 필요해서 급조 합니다.

 

참고문서)

docs.python.org/ko/3/library/asyncio.html

docs.python-requests.org/en/master/

$ pyenv virtualenv 3.8.6 helloworld
$ pyenv activate helloworld
(helloworld) $ pip install requests asyncio
(helloworld) $ python asyncio.py

(helloworld) $ vi asyncio.py
import requests
import string
import random
import asyncio

async def requestAsyncio(content, cid, aid):
    url = "http://localhost:8080/helloworld"

    payload={}

    headers = {
      'accept': 'application/json, text/plain, */*',
      'accept-encoding': 'gzip, deflate, br',
      'accept-language': 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5,zh-MO;q=0.4,zh;q=0.3',
      'content-type': 'application/x-www-form-urlencoded',
      'origin': 'http://localhost:8080',
      'referer': 'http://localhost:8080/helloworld',
      'sec-fetch-dest': 'empty',
      'sec-fetch-mode': 'cors',
      'sec-fetch-site': 'same-site',
      'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
    }

    response = requests.request("POST", url, headers=headers, data=payload)

    print(response.status_code)
    print(response.text)

if __name__ == "__main__":
    letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

    cid = "helloworld"
    aid = "python"
    content1 = random.choice(letters)
    content2 = random.choice(letters)

    loop = asyncio.get_event_loop()
    loop.run_until_complete(asyncio.gather(requestKhan(content1, cid, aid), requestKhan(content2, cid, aid)))
    loop.close()
    
(helloworld) $ python asyncio.py

(helloworld) $ pyenv deactivate helloworld
$

 

:

[Spring] Event Pub/Sub 기능 예제

ITWeb/개발일반 2021. 3. 3. 11:23

Spring 을 이용해서 간단한 Pub/Sub 기능을 구현 할 수 있는 예제 입니다.

 

관련 Class & Annotation)

ApplicationEventPublisher

@EventListener

 

Pub & Sub 을 위한 Topic Payload)

CustomEventTopicPayload

 

Subscriber Class)

CustomEventSubscriber

 

Code Example)

HelloController : Publisher

@Controller
public class HelloController {

  @Autowired
  ApplicationEventPublisher eventPublisher;

  @GetMapping ("/poc/hello")
  public String hello() {

    eventPublisher.publishEvent(new CustomEventTopicPayload(this, 100));

    return "poc/hello";
  }
}

 

CustomEventSubscriber - Subscriber

@Component
@Log4j2
public class CustomEventSubscriber {

  @EventListener
  public void onEventListener(CustomEventTopicPayload topic) {
    log.debug("{} Topic payload: " + topic.getData(), Thread.currentThread().toString());
  }
}

 

CustomEventTopicPayload - Topic Payload

@Getter
@Setter
public class CustomEventTopicPayload {
  private Object source;
  private int data;

  public CustomEventTopicPayload(Object source) {
    this(source, 0);
  }

  public CustomEventTopicPayload(Object source, int data) {
    this.source = source;
    this.data = data;
  }
}

 

아래 간략한 코드 스니핑은 스프링 4.2 이전 방식 입니다.

public class CustomEventTopicPayload extends ApplicationEvent {}

public class CustomEventSubscriber implements ApplicationListener<CustomEventTopicPayload>{}

 

:

[Spring] 멀티모듈 프로젝트 jar SKIPPED

ITWeb/개발일반 2021. 2. 22. 18:24

intellij community 를 사용하고 있는데 다른 사람은 다 되는게 나만 안되어서 설정을 고쳐서 해결 했습니다.

다른 사람들은 intellij ultimate 사용 하고 있습니다.

 

Multi module web 프로젝트 실행 시 submodule 만 동작해서 원인을 찾아 보고 해결했습니다.

 

원인은)

> Task :base:compileJava UP-TO-DATE
> Task :base:processResources NO-SOURCE
> Task :base:classes UP-TO-DATE
> Task :base:jar SKIPPED
> Task :custom:compileJava UP-TO-DATE
> Task :custom:processResources NO-SOURCE
> Task :custom:classes UP-TO-DATE

 

해결은)

project(":base") {
  jar{
    enabled = true
  }
}

 

근데 왜 나만 저렇게 설정을 해줘야 하는지는 못 찾았습니다.

아시는 분은 제보 좀...

:

[JQuery] Selectors 링크

ITWeb/개발일반 2021. 2. 15. 11:03

https://www.w3schools.com/jquery/jquery_ref_selectors.asp
http://gregfranko.com/jquery-best-practices/#/5

 

저는 주로 id selector 를 사용 합니다.

 

: