[BAEL-17473] - Moved articles to corrrect places, formatted pom.xmls and added description in readme files

This commit is contained in:
amit2103
2019-10-06 12:27:05 +05:30
parent 4f22a71702
commit be24e03a48
17 changed files with 95 additions and 82 deletions

View File

@@ -1,5 +1,9 @@
## Spring Boot Deployment
This module contains articles about deployment of a Spring Boot Application
### Relevant Articles:
- [Deploy a Spring Boot WAR into a Tomcat Server](https://www.baeldung.com/spring-boot-war-tomcat-deploy)
- [Spring Boot Console Application](https://www.baeldung.com/spring-boot-console-app)
- [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat)
- [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs)
- [Comparing Embedded Servlet Containers in Spring Boot](https://www.baeldung.com/spring-boot-servlet-containers)

View File

@@ -102,14 +102,14 @@
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/conf.properties</exclude>
</excludes>
</resource>
</resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/conf.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@@ -126,28 +126,28 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<!-- Invokes both the integration-test and the verify goals of the Failsafe
Maven plugin -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Skips integration tests if the value of skip.integration.tests
property is true -->
<includes>
<include>**/ExternalPropertyFileLoaderIntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<!-- Invokes both the integration-test and the verify goals of the Failsafe
Maven plugin -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Skips integration tests if the value of skip.integration.tests
property is true -->
<includes>
<include>**/ExternalPropertyFileLoaderIntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@@ -0,0 +1,12 @@
package com.baeldung.compare;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ComparisonApplication {
public static void main(String[] args) {
SpringApplication.run(ComparisonApplication.class, args);
}
}

View File

@@ -0,0 +1,65 @@
package com.baeldung.compare;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Statistic;
@Component
public class StartupEventHandler {
// logger, constructor
private static Logger logger = LoggerFactory.getLogger(StartupEventHandler.class);
public StartupEventHandler(MeterRegistry registry) {
this.meterRegistry = registry;
}
private String[] METRICS = {
"jvm.memory.used",
"jvm.classes.loaded",
"jvm.threads.live"};
private String METRIC_MSG_FORMAT = "Startup Metric >> {}={}";
private MeterRegistry meterRegistry;
@EventListener
public void getAndLogStartupMetrics(
ApplicationReadyEvent event) {
Arrays.asList(METRICS)
.forEach(this::getAndLogActuatorMetric);
}
private void getAndLogActuatorMetric(String metric) {
Meter meter = meterRegistry.find(metric).meter();
Map<Statistic, Double> stats = getSamples(meter);
logger.info(METRIC_MSG_FORMAT, metric, stats.get(Statistic.VALUE).longValue());
}
private Map<Statistic, Double> getSamples(Meter meter) {
Map<Statistic, Double> samples = new LinkedHashMap<>();
mergeMeasurements(samples, meter);
return samples;
}
private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(),
measurement.getValue(), mergeFunction(measurement.getStatistic())));
}
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
return Statistic.MAX.equals(statistic) ? Double::max : Double::sum;
}
}

View File

@@ -1,29 +0,0 @@
# server configuration
server.port=4010
server.address=127.0.0.1
## Error handling configuration
server.error.whitelabel.enabled=true
server.error.path=/user-error
server.error.include-exception=true
server.error.include-stacktrace=always
## Server connections configuration
server.tomcat.max-threads=200
server.connection-timeout=5s
server.max-http-header-size=8KB
server.tomcat.max-swallow-size=2MB
server.tomcat.max-http-post-size=2MB
## Access logs configuration
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.directory=logs
server.tomcat.accesslog.file-date-format=yyyy-MM-dd
server.tomcat.accesslog.prefix=access_log
server.tomcat.accesslog.suffix=.log
server.tomcat.accesslog.pattern=common
server.tomcat.basedir=tomcat
## Tomcat internal server logs
logging.level.org.apache.tomcat=DEBUG
logging.level.org.apache.catalina=DEBUG

View File

@@ -1 +1,7 @@
spring.main.allow-bean-definition-overriding=true
management.endpoints.web.exposure.include=*
management.metrics.enable.root=true
management.metrics.enable.jvm=true
management.endpoint.restart.enabled=true
spring.datasource.jmx-enabled=false
spring.main.allow-bean-definition-overriding=true
management.endpoint.shutdown.enabled=true