Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Widget Connector
urlhttp://youtube.com/watch?v=Pv8iUi4-FOA

Info
  1. 사전 조건
    1. Docker Desktop을 설치 SRRD DevEnv on Desktop PC 환경설정을 검토 합니다.
    2. Windows의 경우 Pro OS가 필요합니다.
    3. Git for Windows를 설치 합니다.
    4. IntelliJ CE버전이 필요 합니다.
  2. IntelliJ에서 Git 프로젝트를 Import 합니다.
  3. IntelliJ Teminal에서 redis container를 실행합니다.
  4. IntelliJ에서 Spring boot 어플리케이션을 실행 합니다.
  5. curl로 호출해 봅니다.


SWRS Docker 배경지식


Info

https://github.com/spring-academy/reactive-link-shortener-sample-app

Info

Table of Contents


1. Git Fork

Image Added

Image Added

2. Git Clone

spring-academy
Code Block
titlegit clone
Info
https://github.com/
Sanses/reactive-link-shortener-sample-app

Image Removed

Image Removed

Image Removed

SanseMac:
reactive-link-shortener-sample-app.git
Cloning 
sanse$ docker run -d -p 6379:6379 --name redis redis Unable to find image 'redis:latest' locally latest: Pulling from library/redis f5d23c7fed46: Already exists a4a5c04dafc1: Already exists 605bafc84bc9: Already exists f07a4e35cd96: Already exists 17944e5e3eb7: Already exists 6f875a8605e0: Already exists Digest: sha256:8888f6cd2509062a377e903e17777b4a6d59c92769f6807f034fa345da9eebcf Status: Downloaded newer image for redis:latest 3a76b32933719cd69fde6a710c1a7b897eb92d42ebcae0ef20dba675419acafb SanseMac:reactive-link-shortener-sample-app sanse$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS
into 'reactive-link-shortener-sample-app'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 73 (delta 2), reused 0 (delta 0), pack-reused 62
Unpacking objects: 100% (73/73), 57.02 KiB | 70.00 KiB/s, done.

C:\Users\sanse\workspace>dir
 Volume in drive C is Windows
 Volume Serial Number is 24E4-A55B

 Directory of C:\Users\sanse\workspace

2020-09-06  오후 09:33    <DIR>          .
2020-09-06  오후 09:33    <DIR>          ..
2020-09-06  오후 09:33    <DIR>          
reactive-link-shortener-sample-app
    
PORTS
           0 File(s)        
NAMES 3a76b3293371
      0 bytes
 
redis
              
"docker-entrypoint.s..." 19 seconds ago Up 17 seconds 0.0.0.0:6379->6379/tcp redis SanseMac:
3 Dir(s)  93,214,756,864 bytes free
.git
C:\Users\sanse\workspace>git clone https://github.com/Sanses/
Info
titledocker run -d -p 6379:6379 --name redis redis
## Redis Container 실행
Code Block

3. Build Application

Code Block
titlemvnw clean package
C:\Users\sanse\workspace\reactive-link-shortener-sample-app>mvnw clean
Found "C:\Users\sanse\workspace\reactive-link-shortener-sample-app
sanse$

Image Removed

\.mvn\wrapper\maven-wrapper.jar"
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.316 s
[INFO] Finished at: 2020-09-06T21:36:09+09:00
[INFO] ------------------------------------------------------------------------

C:\Users\sanse\workspace\reactive-link-shortener-sample-app>mvnw package
Found "C:\Users\sanse\workspace\reactive-link-shortener-sample-app\.mvn\wrapper\maven-wrapper.jar"
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ demo ---

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:11 min
[INFO] Finished at: 2020-09-06T21:38:34+09:00
[INFO] ------------------------------------------------------------------------

4. Run Redis Container

Code Block
languagebash
themeMidnight
titledocker run -d -p 6379:6379 --name redis redis
linenumberstrue
C:\Users\sanse\workspace\reactive-link-shortener-sample-app>docker run -d -p 6379:6379 --name redis redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
bf5952930446: Pull complete
911b8422b695: Pull complete
093b947e0ade: Pull complete
c7616728f575: Pull complete
61a55f107028: Pull complete
0ee3e0cb4e07: Pull complete
Digest: sha256:933c6c01829165885ea8468d87f71127b1cb76a711311e6c63708097e92ee3d1
Status: Downloaded newer image for redis:latest
a1bb2185039c29b801c57ee99644c3179481b33dd73d58fcde90bcf2099a89dc
 

5. Run Application

Code Block
titlejava -jar demo-0.0.1-SNAPSHOT.jar
C:\Users\sanse\workspace\reactive-link-shortener-sample-app\target>java -jar demo-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2020-09-06 21:43:31.839  WARN 11288
Code Block
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java "-javaagent:/Users/sanse/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/191.7479.19/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=49869:/Users/sanse/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/191.7479.19/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/tools.jar:/Users/sanse/Documents/reactive-link-shortener-sample-app/target/classes:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis-reactive/2.1.0.RELEASE/spring-boot-starter-data-redis-reactive-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.1.0.RELEASE/spring-boot-starter-data-redis-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/data/spring-data-redis/2.1.2.RELEASE/spring-data-redis-2.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/data/spring-data-keyvalue/2.1.2.RELEASE/spring-data-keyvalue-2.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/data/spring-data-commons/2.1.2.RELEASE/spring-data-commons-2.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-tx/5.1.2.RELEASE/spring-tx-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-oxm/5.1.2.RELEASE/spring-oxm-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-aop/5.1.2.RELEASE/spring-aop-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-context-support/5.1.2.RELEASE/spring-context-support-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/io/lettuce/lettuce-core/5.1.2.RELEASE/lettuce-core-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/io/netty/netty-common/4.1.29.Final/netty-common-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-transport/4.1.29.Final/netty-transport-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-resolver/4.1.29.Final/netty-resolver-4.1.29.Final.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-webflux/2.1.0.RELEASE/spring-boot-starter-webflux-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter/2.1.0.RELEASE/spring-boot-starter-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot/2.1.0.RELEASE/spring-boot-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-context/5.1.2.RELEASE/spring-context-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-expression/5.1.2.RELEASE/spring-expression-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.0.RELEASE/spring-boot-autoconfigure-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.1.0.RELEASE/spring-boot-starter-logging-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/sanse/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/sanse/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.11.1/log4j-to-slf4j-2.11.1.jar:/Users/sanse/.m2/repository/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar:/Users/sanse/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/Users/sanse/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/sanse/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.1.0.RELEASE/spring-boot-starter-json-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.7/jackson-databind-2.9.7.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.7/jackson-core-2.9.7.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.7/jackson-datatype-jdk8-2.9.7.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.7/jackson-datatype-jsr310-2.9.7.jar:/Users/sanse/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.7/jackson-module-parameter-names-2.9.7.jar:/Users/sanse/.m2/repository/org/springframework/boot/spring-boot-starter-reactor-netty/2.1.0.RELEASE/spring-boot-starter-reactor-netty-2.1.0.RELEASE.jar:/Users/sanse/.m2/repository/io/projectreactor/netty/reactor-netty/0.8.2.RELEASE/reactor-netty-0.8.2.RELEASE.jar:/Users/sanse/.m2/repository/io/netty/netty-codec-http2/4.1.29.Final/netty-codec-http2-4.1.29.Final.jar:/Users/sanse/.m2/repository/org/hibernate/validator/hibernate-validator/6.0.13.Final/hibernate-validator-6.0.13.Final.jar:/Users/sanse/.m2/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Users/sanse/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/sanse/.m2/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/sanse/.m2/repository/org/springframework/spring-web/5.1.2.RELEASE/spring-web-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-beans/5.1.2.RELEASE/spring-beans-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-webflux/5.1.2.RELEASE/spring-webflux-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/synchronoss/cloud/nio-multipart-parser/1.1.0/nio-multipart-parser-1.1.0.jar:/Users/sanse/.m2/repository/org/synchronoss/cloud/nio-stream-storage/1.1.3/nio-stream-storage-1.1.3.jar:/Users/sanse/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar:/Users/sanse/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar:/Users/sanse/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/sanse/.m2/repository/io/netty/netty-codec-http/4.1.29.Final/netty-codec-http-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-codec/4.1.29.Final/netty-codec-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-handler/4.1.29.Final/netty-handler-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-buffer/4.1.29.Final/netty-buffer-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-handler-proxy/4.1.29.Final/netty-handler-proxy-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-codec-socks/4.1.29.Final/netty-codec-socks-4.1.29.Final.jar:/Users/sanse/.m2/repository/io/netty/netty-transport-native-epoll/4.1.29.Final/netty-transport-native-epoll-4.1.29.Final-linux-x86_64.jar:/Users/sanse/.m2/repository/io/netty/netty-transport-native-unix-common/4.1.29.Final/netty-transport-native-unix-common-4.1.29.Final.jar:/Users/sanse/.m2/repository/org/springframework/spring-core/5.1.2.RELEASE/spring-core-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/org/springframework/spring-jcl/5.1.2.RELEASE/spring-jcl-5.1.2.RELEASE.jar:/Users/sanse/.m2/repository/io/projectreactor/reactor-core/3.2.2.RELEASE/reactor-core-3.2.2.RELEASE.jar:/Users/sanse/.m2/repository/org/reactivestreams/reactive-streams/1.0.2/reactive-streams-1.0.2.jar com.example.demo.DemoApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2019-07-21 09:17:03.854  INFO 4175 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication on SanseMac.local with PID 4175 (/Users/sanse/Documents/reactive-link-shortener-sample-app/target/classes started by sanse in /Users/sanse/Documents/reactive-link-shortener-sample-app)
2019-07-21 09:17:03.864  INFO 4175 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2019-07-21 09:17:05.635  INFO 4175 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-07-21 09:17:05.639  INFO 4175 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-07-21 09:17:05.682  INFO 4175 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 26ms. Found 0 repository interfaces.
2019-07-21 09:17:06.419  WARN 4175 --- [           main] reactor.netty.tcp.TcpResources           : [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=4, workerCount=4}
20192020-0709-06 21 09:1743:0631.419855  WARN 417511288 --- [           main] reactor.netty.tcp.TcpResources           : [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$194ConnectionProvider$$Lambda$198/2088582214@24fb6a80233021551@76b10754}
20192020-0709-06 21 09:1743:0937.606550  INFO 417511288 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
20192020-0709-06 21 09:1743:0937.622566  INFO 417511288 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 611.937739 seconds (JVM running for 8.438)13.57)

6. Call Api

## 어플리케이션 실행code
Code Block
languagebash
themeMidnight
Info
iconfalse
titlecurl -XPOST http://localhost:8080/link -H "Content-Type: application/json" -d '"{\"link\":\"http://wiki.iisanse.com\"}'"
linenumbers
true
SanseMac:
C:\Users\sanse\workspace\reactive-link-shortener-sample-
app sanse$ curl
app>curl -XPOST http://localhost:8080/link -H "Content-Type: application/json" -d 
'
"{\"link\":\"http://wiki.iisanse.com\"}
'
"
{"shortenedLink":"http://localhost:8080/
mrfTuM
ruEadd"}
SanseMac:reactive-link-shortener-sample-app sanse$