hikaricp module (#1781)
* jvm log forging * jvm log forging * jvm log forging * log forging * adding hikariCP module * try-with-resources * adding employee use case
This commit is contained in:
parent
0be7de2c42
commit
1cc1f703be
|
@ -1,328 +1,413 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>core-java</artifactId>
|
<artifactId>core-java</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>core-java</name>
|
<name>core-java</name>
|
||||||
|
|
||||||
<parent>
|
<dependencies>
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-modules</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
<!-- utils -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sourceforge.collections</groupId>
|
||||||
|
<artifactId>collections-generic</artifactId>
|
||||||
|
<version>${collections-generic.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- utils -->
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.apache.commons</groupId>
|
||||||
<groupId>net.sourceforge.collections</groupId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
<artifactId>collections-generic</artifactId>
|
<version>${commons-collections4.version}</version>
|
||||||
<version>${collections-generic.version}</version>
|
</dependency>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>${guava.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-collections4.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-math3</artifactId>
|
||||||
<version>${commons-lang3.version}</version>
|
<version>${commons-math3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>commons-math3</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>${commons-math3.version}</version>
|
<version>${bouncycastle.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.unix4j</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>unix4j-command</artifactId>
|
||||||
<version>${bouncycastle.version}</version>
|
<version>${unix4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.unix4j</groupId>
|
<groupId>com.googlecode.grep4j</groupId>
|
||||||
<artifactId>unix4j-command</artifactId>
|
<artifactId>grep4j</artifactId>
|
||||||
<version>${unix4j.version}</version>
|
<version>${grep4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- web -->
|
||||||
|
|
||||||
<dependency>
|
<!-- marshalling -->
|
||||||
<groupId>com.googlecode.grep4j</groupId>
|
|
||||||
<artifactId>grep4j</artifactId>
|
|
||||||
<version>${grep4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- web -->
|
|
||||||
|
|
||||||
<!-- marshalling -->
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- logging -->
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>${logback.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||||
|
</dependency>
|
||||||
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- mysql -->
|
<!-- test scoped -->
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<version>${mysql.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- test scoped -->
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-all</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${assertj.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.awaitility</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>awaitility</artifactId>
|
<artifactId>hamcrest-core</artifactId>
|
||||||
<version>${avaitility.version}</version>
|
<version>${org.hamcrest.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-library</artifactId>
|
||||||
|
<version>${org.hamcrest.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>${commons-codec.version}</version>
|
<version>${assertj.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javamoney</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>moneta</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>1.1</version>
|
<version>${testng.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.owasp.esapi</groupId>
|
|
||||||
<artifactId>esapi</artifactId>
|
|
||||||
<version>2.1.0.1</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.owasp.esapi</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>esapi</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>2.1.0.1</version>
|
<version>${mockito.version}</version>
|
||||||
<exclusions>
|
<scope>test</scope>
|
||||||
<exclusion>
|
</dependency>
|
||||||
<artifactId>commons-logging</artifactId>
|
<dependency>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>com.jayway.awaitility</groupId>
|
||||||
</exclusion>
|
<artifactId>awaitility</artifactId>
|
||||||
</exclusions>
|
<version>${avaitility.version}</version>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons-codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
<dependency>
|
||||||
<finalName>core-java</finalName>
|
<groupId>org.javamoney</groupId>
|
||||||
<resources>
|
<artifactId>moneta</artifactId>
|
||||||
<resource>
|
<version>1.1</version>
|
||||||
<directory>src/main/resources</directory>
|
</dependency>
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<dependency>
|
||||||
<plugin>
|
<groupId>org.owasp.esapi</groupId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<artifactId>esapi</artifactId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<version>2.1.0.1</version>
|
||||||
<executions>
|
</dependency>
|
||||||
<execution>
|
|
||||||
<id>copy-dependencies</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>com.zaxxer</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<configuration>
|
<version>2.6.1</version>
|
||||||
<archive>
|
<scope>compile</scope>
|
||||||
<manifest>
|
</dependency>
|
||||||
<addClasspath>true</addClasspath>
|
|
||||||
<classpathPrefix>libs/</classpathPrefix>
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>single</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
|
|
||||||
<archive>
|
|
||||||
<manifest>
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
|
||||||
<transformers>
|
|
||||||
<transformer
|
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
</transformer>
|
|
||||||
</transformers>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.jolira</groupId>
|
|
||||||
<artifactId>onejar-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
<attachToBuild>true</attachToBuild>
|
|
||||||
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
|
|
||||||
</configuration>
|
|
||||||
<goals>
|
|
||||||
<goal>one-jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<classifier>spring-boot</classifier>
|
|
||||||
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
|
|
||||||
</build>
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<profiles>
|
</dependencies>
|
||||||
<profile>
|
|
||||||
<id>integration</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*ManualTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>**/*IntegrationTest.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<test.mime>json</test.mime>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
<build>
|
||||||
<!-- marshalling -->
|
<finalName>core-java</finalName>
|
||||||
<jackson.version>2.8.5</jackson.version>
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
<!-- mysql -->
|
<plugins>
|
||||||
<mysql.version>6.0.6</mysql.version>
|
|
||||||
|
|
||||||
<!-- util -->
|
<plugin>
|
||||||
<guava.version>21.0</guava.version>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<commons-lang3.version>3.5</commons-lang3.version>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<bouncycastle.version>1.55</bouncycastle.version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<commons-codec.version>1.10</commons-codec.version>
|
<configuration>
|
||||||
<commons-math3.version>3.6.1</commons-math3.version>
|
<source>1.8</source>
|
||||||
<commons-io.version>2.5</commons-io.version>
|
<target>1.8</target>
|
||||||
<commons-collections4.version>4.1</commons-collections4.version>
|
</configuration>
|
||||||
<collections-generic.version>4.01</collections-generic.version>
|
</plugin>
|
||||||
<unix4j.version>0.4</unix4j.version>
|
|
||||||
<grep4j.version>1.8.7</grep4j.version>
|
|
||||||
<lombok.version>1.16.12</lombok.version>
|
|
||||||
|
|
||||||
<!-- testing -->
|
<plugin>
|
||||||
<assertj.version>3.6.1</assertj.version>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<avaitility.version>1.7.0</avaitility.version>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||||
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</properties>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-dependencies</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</project>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>libs/</classpathPrefix>
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||||
|
<transformers>
|
||||||
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</transformer>
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.jolira</groupId>
|
||||||
|
<artifactId>onejar-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
<attachToBuild>true</attachToBuild>
|
||||||
|
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>one-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<classifier>spring-boot</classifier>
|
||||||
|
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>integration</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*ManualTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
|
<include>**/*IntegrationTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<test.mime>json</test.mime>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- marshalling -->
|
||||||
|
<jackson.version>2.8.5</jackson.version>
|
||||||
|
|
||||||
|
<!-- logging -->
|
||||||
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
|
<logback.version>1.1.7</logback.version>
|
||||||
|
|
||||||
|
<!-- util -->
|
||||||
|
<guava.version>21.0</guava.version>
|
||||||
|
<commons-lang3.version>3.5</commons-lang3.version>
|
||||||
|
<bouncycastle.version>1.55</bouncycastle.version>
|
||||||
|
<commons-codec.version>1.10</commons-codec.version>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<commons-io.version>2.5</commons-io.version>
|
||||||
|
<commons-collections4.version>4.1</commons-collections4.version>
|
||||||
|
<collections-generic.version>4.01</collections-generic.version>
|
||||||
|
<unix4j.version>0.4</unix4j.version>
|
||||||
|
<grep4j.version>1.8.7</grep4j.version>
|
||||||
|
<lombok.version>1.16.12</lombok.version>
|
||||||
|
|
||||||
|
<!-- testing -->
|
||||||
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<mockito.version>1.10.19</mockito.version>
|
||||||
|
<testng.version>6.10</testng.version>
|
||||||
|
<assertj.version>3.6.1</assertj.version>
|
||||||
|
<avaitility.version>1.7.0</avaitility.version>
|
||||||
|
|
||||||
|
<!-- maven plugins -->
|
||||||
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
|
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.baeldung.hikaricp;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
|
public class DataSource {
|
||||||
|
|
||||||
|
private static HikariConfig config = new HikariConfig();
|
||||||
|
private static HikariDataSource ds;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// config = new HikariConfig("datasource.properties");
|
||||||
|
|
||||||
|
// Properties props = new Properties();
|
||||||
|
// props.setProperty("dataSourceClassName", "org.postgresql.ds.PGSimpleDataSource");
|
||||||
|
// props.setProperty("dataSource.user", "postgres");
|
||||||
|
// props.setProperty("dataSource.password", "postgres");
|
||||||
|
// props.setProperty("dataSource.databaseName", "postgres");
|
||||||
|
// props.setProperty("dataSource.portNumber", "5432");
|
||||||
|
// props.setProperty("dataSource.serverName", "localhost");
|
||||||
|
// props.put("dataSource.logWriter", new PrintWriter(System.out));
|
||||||
|
// config = new HikariConfig(props);
|
||||||
|
|
||||||
|
config.setJdbcUrl("jdbc:postgresql://localhost:5432/postgres");
|
||||||
|
config.setUsername("postgres");
|
||||||
|
config.setPassword("postgres");
|
||||||
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
|
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||||
|
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||||
|
ds = new HikariDataSource(config);
|
||||||
|
|
||||||
|
// ds.setJdbcUrl("jdbc:postgresql://localhost:5432/postgres");
|
||||||
|
// ds.setUsername("postgres");
|
||||||
|
// ds.setPassword("postgres");
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataSource() {}
|
||||||
|
|
||||||
|
public static Connection getConnection() throws SQLException {
|
||||||
|
return ds.getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.baeldung.hikaricp;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
private int empNo;
|
||||||
|
private String ename;
|
||||||
|
private String job;
|
||||||
|
private int mgr;
|
||||||
|
private Date hiredate;
|
||||||
|
private int sal;
|
||||||
|
private int comm;
|
||||||
|
private int deptno;
|
||||||
|
|
||||||
|
public int getEmpNo() {
|
||||||
|
return empNo;
|
||||||
|
}
|
||||||
|
public void setEmpNo(int empNo) {
|
||||||
|
this.empNo = empNo;
|
||||||
|
}
|
||||||
|
public String getEname() {
|
||||||
|
return ename;
|
||||||
|
}
|
||||||
|
public void setEname(String ename) {
|
||||||
|
this.ename = ename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJob() {
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
public void setJob(String job) {
|
||||||
|
this.job = job;
|
||||||
|
}
|
||||||
|
public int getMgr() {
|
||||||
|
return mgr;
|
||||||
|
}
|
||||||
|
public void setMgr(int mgr) {
|
||||||
|
this.mgr = mgr;
|
||||||
|
}
|
||||||
|
public Date getHiredate() {
|
||||||
|
return hiredate;
|
||||||
|
}
|
||||||
|
public void setHiredate(Date hiredate) {
|
||||||
|
this.hiredate = hiredate;
|
||||||
|
}
|
||||||
|
public int getSal() {
|
||||||
|
return sal;
|
||||||
|
}
|
||||||
|
public void setSal(int sal) {
|
||||||
|
this.sal = sal;
|
||||||
|
}
|
||||||
|
public int getComm() {
|
||||||
|
return comm;
|
||||||
|
}
|
||||||
|
public void setComm(int comm) {
|
||||||
|
this.comm = comm;
|
||||||
|
}
|
||||||
|
public int getDeptno() {
|
||||||
|
return deptno;
|
||||||
|
}
|
||||||
|
public void setDeptno(int deptno) {
|
||||||
|
this.deptno = deptno;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Employee [empNo=" + empNo + ", ename=" + ename + ", job=" + job + ", mgr=" + mgr + ", hiredate="
|
||||||
|
+ hiredate + ", sal=" + sal + ", comm=" + comm + ", deptno=" + deptno + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.baeldung.hikaricp;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HikariCPDemo {
|
||||||
|
|
||||||
|
public static List<Employee> fetchData() {
|
||||||
|
final String SQL_QUERY = "select * from emp";
|
||||||
|
List<Employee> employees = null;
|
||||||
|
try (Connection con = DataSource.getConnection();
|
||||||
|
PreparedStatement pst = con.prepareStatement(SQL_QUERY);
|
||||||
|
ResultSet rs = pst.executeQuery();) {
|
||||||
|
employees = new ArrayList<Employee>();
|
||||||
|
Employee employee;
|
||||||
|
while (rs.next()) {
|
||||||
|
employee = new Employee();
|
||||||
|
employee.setEmpNo(rs.getInt("empno"));
|
||||||
|
employee.setEname(rs.getString("ename"));
|
||||||
|
employee.setJob(rs.getString("job"));
|
||||||
|
employee.setMgr(rs.getInt("mgr"));
|
||||||
|
employee.setHiredate(rs.getDate("hiredate"));
|
||||||
|
employee.setSal(rs.getInt("sal"));
|
||||||
|
employee.setComm(rs.getInt("comm"));
|
||||||
|
employee.setDeptno(rs.getInt("deptno"));
|
||||||
|
employees.add(employee);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
create table dept(
|
||||||
|
deptno numeric,
|
||||||
|
dname varchar(14),
|
||||||
|
loc varchar(13),
|
||||||
|
constraint pk_dept primary key (deptno)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table emp(
|
||||||
|
empno numeric,
|
||||||
|
ename varchar(10),
|
||||||
|
job varchar(9),
|
||||||
|
mgr numeric,
|
||||||
|
hiredate date,
|
||||||
|
sal numeric,
|
||||||
|
comm numeric,
|
||||||
|
deptno numeric,
|
||||||
|
constraint pk_emp primary key (empno),
|
||||||
|
constraint fk_deptno foreign key (deptno) references dept (deptno)
|
||||||
|
);
|
||||||
|
|
||||||
|
insert into dept values(10, 'ACCOUNTING', 'NEW YORK');
|
||||||
|
insert into dept values(20, 'RESEARCH', 'DALLAS');
|
||||||
|
insert into dept values(30, 'SALES', 'CHICAGO');
|
||||||
|
insert into dept values(40, 'OPERATIONS', 'BOSTON');
|
||||||
|
|
||||||
|
insert into emp values(
|
||||||
|
7839, 'KING', 'PRESIDENT', null,
|
||||||
|
to_date('17-11-1981','dd-mm-yyyy'),
|
||||||
|
7698, null, 10
|
||||||
|
);
|
||||||
|
insert into emp values(
|
||||||
|
7698, 'BLAKE', 'MANAGER', 7839,
|
||||||
|
to_date('1-5-1981','dd-mm-yyyy'),
|
||||||
|
7782, null, 20
|
||||||
|
);
|
||||||
|
insert into emp values(
|
||||||
|
7782, 'CLARK', 'MANAGER', 7839,
|
||||||
|
to_date('9-6-1981','dd-mm-yyyy'),
|
||||||
|
7566, null, 30
|
||||||
|
);
|
||||||
|
insert into emp values(
|
||||||
|
7566, 'JONES', 'MANAGER', 7839,
|
||||||
|
to_date('2-4-1981','dd-mm-yyyy'),
|
||||||
|
7839, null, 40
|
||||||
|
);
|
||||||
|
|
||||||
|
commit;
|
|
@ -0,0 +1,6 @@
|
||||||
|
dataSourceClassName=//TBD
|
||||||
|
dataSource.user=//TBD
|
||||||
|
dataSource.password=//TBD
|
||||||
|
dataSource.databaseName=//TBD
|
||||||
|
dataSource.portNumber=//TBD
|
||||||
|
dataSource.serverName=//TBD
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.hikaricp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class HikariCPTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
// @Ignore
|
||||||
|
public void givenConnection_thenFetchDbData() {
|
||||||
|
List<Employee> employees = HikariCPDemo.fetchData();
|
||||||
|
assertEquals(4, employees.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue