2021.08.16 TIL

새롭게 배운 것 Done

운동

독서

알고리즘

코딩

Maven

Gradle

plugins {
  java
  application // application 플러그인 추가.
}

group = ///
version = "1.0-SNAPSHOT"

repositories {
  mavenCentral()
  google()
}

dependencies {
  testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
  testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

tasks.getByName<Test>("test") {
  useJUnitPlatform()
}

tasks.compileJava {
  options.isFork = true
}

application {
  mainClass.set("///.App")
}

Spring, Spring Framework, Spring Boot

image

Spring Boot

Spring Framework 핵심 개념

Entity

VO

의존성

Java - 몇 가지 새롭게 알게 된 것들

record

import java.util.UUID;

public record OrderItem(UUID productId,
                        long productPrice,
                        long quantity) {
}
var beforeDiscount = orderItems.stream().map(v -> v.productPrice() * v.quantity())
        .reduce(0L, Long::sum);

var

Spring Asserts

<!-- https://mvnrepository.com/artifact/org.springframework/spring -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>
import org.springframework.util.Assert;

Assert.isTrue(order.totalAmount() == 90L, MessageFormat.format("totalAmount {0} is not 90L", order.totalAmount()));

참고 - ArrayList의 add

var orderItems = new ArrayList<OrderItem>() {{
    add(new OrderItem(UUID.randomUUID(), 100L, 1));
}};

깨달은 점 FEELING