...
Info |
---|
|
04. Create Azure Cache for Redis
05. Spring Boot Application 준비
Info | ||
---|---|---|
| ||
...
05-01. Git Clone
Code Block |
---|
C:\workspace$ git clone https://github.com/Sanses/reactive-shorturl-webui.git Cloning into 'reactive-shorturl-webui'... remote: Enumerating objects: 43, done. remote: Counting objects: 100% (43/43), done. remote: Compressing objects: 100% (29/29), done. remote: Total 43 (delta 2), reused 39 (delta 1), pack-reused 0 Unpacking objects: 100% (43/43), done. C:\workspace$ cd reactive-shorturl-webui |
...
05-02. reactive-shorturl-webui Application 소개
Code Block |
---|
C:\workspace\reactive-shorturl-webui$ C:\workspace\reactive-shorturl-webui>mvnw clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.sansae:shorturl >------------------------- [INFO] Building shorturl 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- ~~~~~~~~~~~~~~~~~~~~ 중략 ~~~~~~~~~~~~~~~~~~ [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 23.120 s [INFO] Finished at: 2021-01-02T11:23:04+09:00 [INFO] ------------------------------------------------------------------------ C:\workspace\reactive-shorturl-webui>java -jar target/shorturl-0.0.1-SNAPSHOT.jar 2021-01-02 11:24:43.050 INFO 356 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 8080 2021-01-02 11:24:43.192 INFO 356 --- [ main] com.sansae.shorturl.ShorturlApplication : Started ShorturlApplication in 10.698 seconds (JVM running for 12.343) |
05. Create Azure Cache for Redis
06
...
Code Block | ||||
---|---|---|---|---|
| ||||
# Specify the DNS URI of your Redis cache.
spring.redis.host=redis20201230.redis.cache.windows.net
# Specify the port for your Redis cache.
spring.redis.port=6380
spring.redis.ssl=true
# Specify the access key for your Redis cache.
spring.redis.password=4pgNlZPhbsla7tgi1s2qONb9YgxttV1zlecnkBJ4uxg= |
Code Block | ||||
---|---|---|---|---|
| ||||
package com.example.redisdemo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
@RestController
public class HelloController {
@Autowired
private StringRedisTemplate template;
@RequestMapping("/")
// Define the Hello World controller.
public String hello() {
ValueOperations<String, String> ops = this.template.opsForValue();
// Add a Hello World string to your cache.
String key = "greeting";
if (!this.template.hasKey(key)) {
ops.set(key, "Hello World!");
}
// Return the string from your cache.
return ops.get(key);
}
} |
07. Execute Spring Boot Application for Azure Redis
Code Block |
---|
C:\workspace\redisdemo>mvnw clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.example:redisdemo >------------------------
[INFO] Building redisdemo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
~~~~~~~~~~~~~~~~ 중략 ~~~~~~~~~~~~~~~~~
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.121 s
[INFO] Finished at: 2020-12-30T22:08:19+09:00
[INFO] ------------------------------------------------------------------------
C:\workspace\redisdemo>mvnw spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.example:redisdemo >------------------------
[INFO] Building redisdemo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
~~~~~~~~~~~~~~~~ 중략 ~~~~~~~~~~~~~~~~~~~
2020-12-30 22:10:54.930 INFO 7284 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-12-30 22:10:54.941 INFO 7284 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-30 22:10:54.942 INFO 7284 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2020-12-30 22:10:55.045 INFO 7284 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-12-30 22:10:55.046 INFO 7284 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1340 ms
2020-12-30 22:10:55.526 INFO 7284 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-12-30 22:10:55.807 INFO 7284 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-12-30 22:10:55.820 INFO 7284 --- [ main] c.e.redisdemo.RedisdemoApplication : Started RedisdemoApplication in 2.782 seconds (JVM running for 3.
388)
C:\workspace\redisdemo>curl localhost:8080
Hello World!
C:\workspace\redisdemo>
|
...