This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class InventoryChecker implements HealthIndicator { | |
private final BookRepository bookRepository; | |
private static final int MIN_AMOUNT = 10; | |
public InventoryChecker(BookRepository bookRepository) { | |
this.bookRepository = bookRepository; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface BookRepository extends JpaRepository<Book, Long> { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name = "Book") | |
@Getter | |
public class Book { | |
@Id | |
private Long id; | |
private String name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: monitoring-demo | |
datasource: | |
driverClassName: org.h2.Driver | |
url: jdbc:h2:mem:testdb | |
username: sa | |
password: pass | |
jpa: | |
database-platform: org.hibernate.dialect.H2Dialect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-actuator</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.univocity.demo.rest; | |
import com.univocity.demo.dto.CsvData; | |
import com.univocity.demo.service.CsvDataService; | |
import lombok.RequiredArgsConstructor; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.univocity.demo.service; | |
import com.univocity.demo.dto.CsvData; | |
import com.univocity.parsers.common.processor.BeanListProcessor; | |
import com.univocity.parsers.csv.CsvParser; | |
import com.univocity.parsers.csv.CsvParserSettings; | |
import org.springframework.stereotype.Service; | |
import javax.annotation.PostConstruct; | |
import java.io.InputStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.univocity.demo.dto; | |
import com.univocity.parsers.annotations.Parsed; | |
import lombok.Data; | |
@Data | |
public class CsvData { | |
@Parsed(field = "SERVICE_ID") | |
private String id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter</artifactId> | |
</dependency> | |
<dependency> | |
<artifactId>spring-boot-starter-web</artifactId> | |
<groupId>org.springframework.boot</groupId> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Endpoint(id = "customEndpoint") | |
@Component | |
public class CustomEndpoint { | |
private final Counter myCounter; | |
@ReadOperation | |
public String customEndpoint(int id) { | |
HashMap<Integer, String> fruitsMap = new HashMap<>(); | |
fruitsMap.put(1, "kiwi"); |