diff --git a/core-java-arrays/README.MD b/core-java-arrays/README.MD
new file mode 100644
index 0000000000..9ee6998784
--- /dev/null
+++ b/core-java-arrays/README.MD
@@ -0,0 +1,3 @@
+## Relevant Articles
+
+- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end)
diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md
index e2b12e8819..383fe5da34 100644
--- a/core-java-modules/core-java-8-2/README.md
+++ b/core-java-modules/core-java-8-2/README.md
@@ -3,4 +3,5 @@
## Core Java 8 Cookbooks and Examples (part 2)
### Relevant Articles:
-- [Anonymous Classes in Java](http://www.baeldung.com/)
+- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes)
+- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments)
diff --git a/core-java-modules/core-java-9/README.md b/core-java-modules/core-java-9/README.md
index ecad86ace2..5715520bae 100644
--- a/core-java-modules/core-java-9/README.md
+++ b/core-java-modules/core-java-9/README.md
@@ -20,7 +20,6 @@
- [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar)
- [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation)
- [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api)
-- [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api)
- [Java 9 java.util.Objects Additions](https://www.baeldung.com/java-9-objects-new)
- [Java 9 Reactive Streams](https://www.baeldung.com/java-9-reactive-streams)
- [Java 9 Optional API Additions](https://www.baeldung.com/java-9-optional)
@@ -31,4 +30,4 @@
- [A Guide to Java 9 Modularity](https://www.baeldung.com/java-9-modularity)
- [Java 9 Platform Module API](https://www.baeldung.com/java-9-module-api)
- [Java 9 Platform Logging API](https://www.baeldung.com/java-9-logging-api)
-
+- [Filtering a Stream of Optionals in Java](https://www.baeldung.com/java-filter-stream-of-optional)
diff --git a/core-java-modules/core-java-io/README.md b/core-java-modules/core-java-io/README.md
index 9ce39459dd..6737ad6eb9 100644
--- a/core-java-modules/core-java-io/README.md
+++ b/core-java-modules/core-java-io/README.md
@@ -40,3 +40,4 @@
- [How to Write to a CSV File in Java](https://www.baeldung.com/java-csv)
- [List Files in a Directory in Java](https://www.baeldung.com/java-list-directory-files)
- [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes)
+- [Introduction to the Java NIO Selector](https://www.baeldung.com/java-nio-selector)
diff --git a/core-java-modules/core-java-reflection/README.MD b/core-java-modules/core-java-reflection/README.MD
new file mode 100644
index 0000000000..c8766d6858
--- /dev/null
+++ b/core-java-modules/core-java-reflection/README.MD
@@ -0,0 +1,3 @@
+## Relevant Articles
+
+- [Void Type in Java](https://www.baeldung.com/java-void-type)
diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md
index c2d1b4a06b..65fb5ddb9d 100644
--- a/core-java-modules/core-java/README.md
+++ b/core-java-modules/core-java/README.md
@@ -51,3 +51,4 @@
- [Java Bitwise Operators](https://www.baeldung.com/java-bitwise-operators)
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
- [Making a JSON POST Request With HttpURLConnection](https://www.baeldung.com/httpurlconnection-post)
+- [Convert Hex to ASCII in Java](https://www.baeldung.com/java-convert-hex-to-ascii)
diff --git a/core-java-modules/pre-jpms/README.MD b/core-java-modules/pre-jpms/README.MD
new file mode 100644
index 0000000000..8c9af82ba5
--- /dev/null
+++ b/core-java-modules/pre-jpms/README.MD
@@ -0,0 +1,3 @@
+## Relevant Articles
+
+- [Java 9 Migration Issues and Resolutions](https://www.baeldung.com/java-9-migration-issue)
diff --git a/java-dates-2/README.md b/java-dates-2/README.md
index a6b5c8e574..35286115d4 100644
--- a/java-dates-2/README.md
+++ b/java-dates-2/README.md
@@ -1,2 +1,3 @@
## Relevant Articles:
- [Converting Between LocalDate and XMLGregorianCalendar](https://www.baeldung.com/java-localdate-to-xmlgregoriancalendar)
+- [Convert Time to Milliseconds in Java](https://www.baeldung.com/java-time-milliseconds)
diff --git a/java-strings-2/README.MD b/java-strings-2/README.MD
index 061296382c..edda92221d 100644
--- a/java-strings-2/README.MD
+++ b/java-strings-2/README.MD
@@ -1,3 +1,4 @@
## Relevant Articles
- [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting)
+- [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring)
diff --git a/libraries-2/README.md b/libraries-2/README.md
index 4bcfeaefa1..8243b9f82c 100644
--- a/libraries-2/README.md
+++ b/libraries-2/README.md
@@ -3,4 +3,5 @@
- [A Guide to jBPM with Java](https://www.baeldung.com/jbpm-java)
- [Guide to Classgraph Library](https://www.baeldung.com/classgraph)
+- [Create a Java Command Line Program with Picocli](https://www.baeldung.com/java-picocli-create-command-line-program)
diff --git a/spring-cloud/spring-cloud-eureka/pom.xml b/spring-cloud/spring-cloud-eureka/pom.xml
index 924981765c..e8e3d67805 100644
--- a/spring-cloud/spring-cloud-eureka/pom.xml
+++ b/spring-cloud/spring-cloud-eureka/pom.xml
@@ -32,8 +32,8 @@
- 2.0.1.RELEASE
- Finchley.SR2
+ 2.1.2.RELEASE
+ Greenwich.RELEASE
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml
index 85fa6606d2..04a5bd3e58 100644
--- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/pom.xml
@@ -19,12 +19,10 @@
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
- ${spring-cloud-starter-eureka.version}
org.springframework.boot
spring-boot-starter-web
- ${spring-boot.version}
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml
index 84ba1e28fe..acc436c574 100644
--- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/pom.xml
@@ -18,23 +18,19 @@
org.springframework.cloud
- spring-cloud-starter-feign
- ${spring-cloud-starter-feign.version}
+ spring-cloud-starter-openfeign
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
- ${spring-cloud-starter-eureka.version}
org.springframework.boot
spring-boot-starter-web
- ${spring-boot.version}
org.springframework.boot
spring-boot-starter-thymeleaf
- ${spring-boot.version}
@@ -49,8 +45,4 @@
-
-
- 1.0.0-SNAPSHOT
-
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml
index f51f6d229d..95edba29f9 100644
--- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/pom.xml
@@ -19,7 +19,6 @@
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
- ${spring-cloud-starter-eureka.version}
diff --git a/spring-rest-full/pom.xml b/spring-rest-full/pom.xml
index ee6e5dbe3e..a85393b7a8 100644
--- a/spring-rest-full/pom.xml
+++ b/spring-rest-full/pom.xml
@@ -8,10 +8,10 @@
war
- parent-boot-1
+ parent-boot-2
com.baeldung
0.0.1-SNAPSHOT
- ../parent-boot-1
+ ../parent-boot-2
@@ -129,6 +129,7 @@
org.javassist
javassist
+ ${javassist.version}
mysql
@@ -287,6 +288,7 @@
19.0
3.5
+ 3.25.0-GA
1.6.1
diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java
index 059516eeba..ceefbbe0e3 100644
--- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java
+++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java
@@ -17,7 +17,7 @@ public abstract class AbstractService implements IOperat
@Override
@Transactional(readOnly = true)
public T findOne(final long id) {
- return getDao().findOne(id);
+ return getDao().findById(id).orElse(null);
}
// read - all
diff --git a/spring-rest-full/src/main/java/org/baeldung/spring/Application.java b/spring-rest-full/src/main/java/org/baeldung/spring/Application.java
index 950e2085a6..ca72a4ef56 100644
--- a/spring-rest-full/src/main/java/org/baeldung/spring/Application.java
+++ b/spring-rest-full/src/main/java/org/baeldung/spring/Application.java
@@ -7,7 +7,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.context.request.RequestContextListener;
diff --git a/spring-rest-full/src/main/java/org/baeldung/spring/WebConfig.java b/spring-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
index 86cb93175a..a0db08d93d 100644
--- a/spring-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
+++ b/spring-rest-full/src/main/java/org/baeldung/spring/WebConfig.java
@@ -6,13 +6,13 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@ComponentScan("org.baeldung.web")
@EnableWebMvc
-public class WebConfig extends WebMvcConfigurerAdapter {
+public class WebConfig implements WebMvcConfigurer {
public WebConfig() {
super();
@@ -29,7 +29,6 @@ public class WebConfig extends WebMvcConfigurerAdapter {
// API
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
- super.addViewControllers(registry);
registry.addViewController("/graph.html");
registry.addViewController("/homepage.html");
}
diff --git a/spring-rest-full/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java b/spring-rest-full/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java
index 89e3a22d45..4dcec17b9e 100644
--- a/spring-rest-full/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java
+++ b/spring-rest-full/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java
@@ -6,16 +6,18 @@ import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
-import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
+import io.micrometer.core.instrument.Counter;
+import io.micrometer.core.instrument.Meter;
+import io.micrometer.core.instrument.MeterRegistry;
+
@Service
public class ActuatorMetricService implements IActuatorMetricService {
@Autowired
- private MetricReaderPublicMetrics publicMetrics;
+ private MeterRegistry publicMetrics;
private final List> statusMetricsByMinute;
private final List statusList;
@@ -68,7 +70,7 @@ public class ActuatorMetricService implements IActuatorMetricService {
private void exportMetrics() {
final ArrayList lastMinuteStatuses = initializeStatuses(statusList.size());
- for (final Metric> counterMetric : publicMetrics.metrics()) {
+ for (final Meter counterMetric : publicMetrics.getMeters()) {
updateMetrics(counterMetric, lastMinuteStatuses);
}
@@ -83,17 +85,17 @@ public class ActuatorMetricService implements IActuatorMetricService {
return counterList;
}
- private void updateMetrics(final Metric> counterMetric, final ArrayList statusCount) {
+ private void updateMetrics(final Meter counterMetric, final ArrayList statusCount) {
String status = "";
int index = -1;
int oldCount = 0;
- if (counterMetric.getName().contains("counter.status.")) {
- status = counterMetric.getName().substring(15, 18); // example 404, 200
+ if (counterMetric.getId().getName().contains("counter.status.")) {
+ status = counterMetric.getId().getName().substring(15, 18); // example 404, 200
appendStatusIfNotExist(status, statusCount);
index = statusList.indexOf(status);
oldCount = statusCount.get(index) == null ? 0 : statusCount.get(index);
- statusCount.set(index, counterMetric.getValue().intValue() + oldCount);
+ statusCount.set(index, (int)((Counter) counterMetric).count() + oldCount);
}
}
diff --git a/spring-rest-full/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java b/spring-rest-full/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java
index 852a9fae99..cf30686e52 100644
--- a/spring-rest-full/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java
+++ b/spring-rest-full/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java
@@ -6,20 +6,18 @@ import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.metrics.CounterService;
-import org.springframework.boot.actuate.metrics.Metric;
-import org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository;
-import org.springframework.boot.actuate.metrics.repository.MetricRepository;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
+import io.micrometer.core.instrument.Counter;
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.search.Search;
+
@Service
public class CustomActuatorMetricService implements ICustomActuatorMetricService {
- private MetricRepository repo;
-
@Autowired
- private CounterService counter;
+ private MeterRegistry registry;
private final List> statusMetricsByMinute;
private final List statusList;
@@ -27,7 +25,6 @@ public class CustomActuatorMetricService implements ICustomActuatorMetricService
public CustomActuatorMetricService() {
super();
- repo = new InMemoryMetricRepository();
statusMetricsByMinute = new ArrayList>();
statusList = new ArrayList();
}
@@ -36,9 +33,10 @@ public class CustomActuatorMetricService implements ICustomActuatorMetricService
@Override
public void increaseCount(final int status) {
- counter.increment("status." + status);
- if (!statusList.contains("counter.status." + status)) {
- statusList.add("counter.status." + status);
+ String counterName = "counter.status." + status;
+ registry.counter(counterName).increment(1);
+ if (!statusList.contains(counterName)) {
+ statusList.add(counterName);
}
}
@@ -78,17 +76,16 @@ public class CustomActuatorMetricService implements ICustomActuatorMetricService
@Scheduled(fixedDelay = 60000)
private void exportMetrics() {
- Metric> metric;
final ArrayList statusCount = new ArrayList();
for (final String status : statusList) {
- metric = repo.findOne(status);
- if (metric != null) {
- statusCount.add(metric.getValue().intValue());
- repo.reset(status);
+ Search search = registry.find(status);
+ if (search != null) {
+ Counter counter = search.counter();
+ statusCount.add(counter != null ? ((int) counter.count()) : 0);
+ registry.remove(counter);
} else {
statusCount.add(0);
}
-
}
statusMetricsByMinute.add(statusCount);
}
diff --git a/spring-rest-full/src/main/resources/application.properties b/spring-rest-full/src/main/resources/application.properties
index 6c7461f12c..52d93b4cff 100644
--- a/spring-rest-full/src/main/resources/application.properties
+++ b/spring-rest-full/src/main/resources/application.properties
@@ -1,3 +1,3 @@
server.port=8082
-server.context-path=/spring-rest-full
+server.servlet.context-path=/spring-rest-full
endpoints.metrics.enabled=true
\ No newline at end of file