[BAEL-14774] - Fixed conflicts and replaced hsql with h2

This commit is contained in:
amit2103 2019-07-08 00:21:11 +05:30
commit 3c92bf292f
109 changed files with 1269 additions and 172 deletions

View File

@ -42,7 +42,7 @@
<dependency>
<groupId>com.github.dpaukov</groupId>
<artifactId>combinatoricslib3</artifactId>
<version>3.3.0</version>
<version>${combinatoricslib3.version}</version>
</dependency>
</dependencies>
@ -83,6 +83,7 @@
<org.assertj.core.version>3.9.0</org.assertj.core.version>
<commons-codec.version>1.11</commons-codec.version>
<guava.version>27.0.1-jre</guava.version>
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
</properties>
</project>

View File

@ -5,3 +5,5 @@
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -1,3 +1,4 @@
### Relevant Articles:
- [Introduction to AutoValue](http://www.baeldung.com/introduction-to-autovalue)
- [Introduction to AutoFactory](http://www.baeldung.com/autofactory)
- [Google AutoService](https://www.baeldung.com/google-autoservice)

View File

@ -7,3 +7,4 @@
- [Groovy def Keyword](https://www.baeldung.com/groovy-def-keyword)
- [Pattern Matching in Strings in Groovy](https://www.baeldung.com/groovy-pattern-matching)
- [Working with XML in Groovy](https://www.baeldung.com/groovy-xml)
- [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications)

View File

@ -3,3 +3,4 @@
- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms)
- [Guide to Java FileChannel](https://www.baeldung.com/java-filechannel)
- [Understanding the NumberFormatException in Java](https://www.baeldung.com/java-number-format-exception)
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)

View File

@ -5,3 +5,4 @@
- [Guide to Java 10](http://www.baeldung.com/java-10-overview)
- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
- [Deep Dive Into the New Java JIT Compiler Graal](https://www.baeldung.com/graal-java-jit-compiler)
- [Copying Sets in Java](https://www.baeldung.com/java-copy-sets)

View File

@ -6,3 +6,4 @@
- [Anonymous Classes in Java](http://www.baeldung.com/)
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments)
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)

View File

@ -40,3 +40,4 @@
- [Java 8 Predicate Chain](https://www.baeldung.com/java-predicate-chain)
- [Method References in Java](https://www.baeldung.com/java-method-references)
- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation)
- [The Difference Between Collection.stream().forEach() and Collection.forEach()](https://www.baeldung.com/java-collection-stream-foreach)

View File

@ -10,3 +10,4 @@
- [Initializing HashSet at the Time of Construction](http://www.baeldung.com/java-initialize-hashset)
- [Guide to EnumSet](https://www.baeldung.com/java-enumset)
- [Set Operations in Java](https://www.baeldung.com/java-set-operations)
- [Copying Sets in Java](https://www.baeldung.com/java-copy-sets)

View File

@ -27,17 +27,18 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<version>${commons-lang.version}</version>
</dependency>
</dependencies>
<properties>
<commons-collections4.version>4.3</commons-collections4.version>
<guava.version>27.1-jre</guava.version>
<gson.version>2.8.5</gson.version>
</properties>
</project>

View File

@ -22,7 +22,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -6,3 +6,4 @@
- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors)
- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error)
- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes)
- [Raw Types in Java](https://www.baeldung.com/raw-types-java)

View File

@ -1,3 +1,3 @@
## Relevant articles:
- [Determine File Creating Date in Java](https://www.baeldung.com/file-creation-date-java)
- [Determine File Creating Date in Java](https://www.baeldung.com/java-file-creation-date)

View File

@ -3,3 +3,4 @@
## Core Java Optional
### Relevant Articles:
- [Java Optional as Return Type](https://www.baeldung.com/java-optional-return)

View File

@ -19,13 +19,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.2</version>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -58,5 +58,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<assertj-core.version>3.12.2</assertj-core.version>
</properties>
</project>

View File

@ -18,7 +18,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>${org.slf4j.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -9,4 +9,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field)
- [How to Process YAML with Jackson](https://www.baeldung.com/jackson-yaml)
- [Working with Tree Model Nodes in Jackson](https://www.baeldung.com/jackson-json-node-tree-model)
- [Converting JSON to CSV in Java](https://www.baeldung.com/java-converting-json-to-csv)

View File

@ -26,21 +26,21 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.9.8</version>
<version>${jackson.version}</version>
</dependency>
<!-- CSV -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>2.9.8</version>
<version>${jackson.version}</version>
</dependency>
<!-- Allow use of LocalDate -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
<version>${jackson.version}</version>
</dependency>

View File

@ -11,3 +11,6 @@
- [How to Convert List to Map in Java](http://www.baeldung.com/java-list-to-map)
- [Array to String Conversions](https://www.baeldung.com/java-array-to-string)
- [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist)
- [Java 8 Collectors toMap](https://www.baeldung.com/java-collectors-tomap)
- [Converting Iterable to Collection in Java](https://www.baeldung.com/java-iterable-to-collection)
- [Converting Iterator to List](https://www.baeldung.com/java-convert-iterator-to-list)

View File

@ -1,4 +1,4 @@
package org.baeldung.java.collections;
package com.baeldung.java.collections;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertThat;

View File

@ -25,7 +25,7 @@
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
<version>${commons-validator.version}</version>
</dependency>
<!-- test scoped -->
@ -63,6 +63,7 @@
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<joda-time.version>2.10</joda-time.version>
<commons-validator.version>1.6</commons-validator.version>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
</properties>

View File

@ -42,7 +42,7 @@
<dependency>
<groupId>com.github.dpaukov</groupId>
<artifactId>combinatoricslib3</artifactId>
<version>3.3.0</version>
<version>${combinatoricslib3.version}</version>
</dependency>
</dependencies>
@ -63,6 +63,7 @@
<org.assertj.core.version>3.9.0</org.assertj.core.version>
<commons-codec.version>1.11</commons-codec.version>
<guava.version>27.0.1-jre</guava.version>
<combinatoricslib3.version>3.3.0</combinatoricslib3.version>
</properties>
</project>

View File

@ -1,3 +1,4 @@
### Relevant Articles:
- [Guide to Stream.reduce()](https://www.baeldung.com/java-stream-reduce)
- [How to Break from Java Stream forEach](https://www.baeldung.com/java-break-stream-foreach)
- [Java IntStream Conversions](https://www.baeldung.com/java-intstream-convert)

3
kotlin-quasar/README.md Normal file
View File

@ -0,0 +1,3 @@
### Relevant Articles
- [Introduction to Quasar in Kotlin](https://www.baeldung.com/kotlin-quasar)

View File

@ -5,3 +5,6 @@
- [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)
- [Guide to Java Parallel Collectors Library](https://www.baeldung.com/java-parallel-collectors)
- [Templating with Handlebars](https://www.baeldung.com/handlebars)
- [A Guide to Crawler4j](https://www.baeldung.com/crawler4j)
- [Decode an OkHttp JSON Response](https://www.baeldung.com/okhttp-json-response)

View File

@ -34,7 +34,7 @@
<dependency>
<groupId>com.pivovarit</groupId>
<artifactId>parallel-collectors</artifactId>
<version>1.1.0</version>
<version>${parallel-collectors.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
@ -96,22 +96,22 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.2</version>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>3.14.2</version>
<version>${mockwebserver.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@ -122,7 +122,7 @@
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.1.2</version>
<version>${handlebars.version}</version>
</dependency>
<!-- Benchmarking -->
<dependency>
@ -156,5 +156,10 @@
<la4j.version>0.6.0</la4j.version>
<jmh.version>1.19</jmh.version>
<mesos.library.version>0.28.3</mesos.library.version>
<parallel-collectors.version>1.1.0</parallel-collectors.version>
<okhttp.version>3.14.2</okhttp.version>
<gson.version>2.8.5</gson.version>
<mockwebserver.version>3.14.2</mockwebserver.version>
<handlebars.version>4.1.2</handlebars.version>
</properties>
</project>

7
libraries-http/README.md Normal file
View File

@ -0,0 +1,7 @@
### Relevant Articles:
- [A Guide to OkHttp](http://www.baeldung.com/guide-to-okhttp)
- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client)
- [Asynchronous HTTP with async-http-client in Java](http://www.baeldung.com/async-http-client)
- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets)

81
libraries-http/pom.xml Normal file
View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-http</artifactId>
<name>libraries-http</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<!-- Dependencies for response decoder with okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${com.squareup.okhttp3.version}</version>
</dependency>
<!-- Dependencies for google http client -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>${googleclient.version}</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>${googleclient.version}</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
<version>${googleclient.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>${async.http.client.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>${com.squareup.okhttp3.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<assertj.version>3.6.2</assertj.version>
<com.squareup.okhttp3.version>3.14.2</com.squareup.okhttp3.version>
<googleclient.version>1.23.0</googleclient.version>
<async.http.client.version>2.2.0</async.http.client.version>
</properties>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -19,6 +19,9 @@ import okhttp3.Response;
import org.junit.Before;
import org.junit.Test;
/**
* Execute <code>spring-rest</code> module before running this live test
*/
public class OkHttpFileUploadingLiveTest {
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";

View File

@ -17,6 +17,9 @@ import okhttp3.Response;
import org.junit.Before;
import org.junit.Test;
/**
* Execute <code>spring-rest</code> module before running this live test
*/
public class OkHttpGetLiveTest {
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";

View File

@ -20,6 +20,9 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Execute <code>spring-rest</code> module before running this live test
*/
public class OkHttpMiscLiveTest {
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";

View File

@ -20,6 +20,9 @@ import okhttp3.Response;
import org.junit.Before;
import org.junit.Test;
/**
* Execute <code>spring-rest</code> module before running this live test
*/
public class OkHttpPostingLiveTest {
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";

View File

@ -36,14 +36,11 @@
- [Introduction To Docx4J](http://www.baeldung.com/docx4j)
- [Introduction to StreamEx](http://www.baeldung.com/streamex)
- [Introduction to BouncyCastle with Java](http://www.baeldung.com/java-bouncy-castle)
- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client)
- [Interact with Google Sheets from Java](http://www.baeldung.com/google-sheets-java-client)
- [A Docker Guide for Java](http://www.baeldung.com/docker-java-api)
- [Introduction To OpenCSV](http://www.baeldung.com/opencsv)
- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
- [Asynchronous HTTP with async-http-client in Java](http://www.baeldung.com/async-http-client)
- [Introduction to Smooks](http://www.baeldung.com/smooks)
- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets)
- [A Guide to Infinispan in Java](http://www.baeldung.com/infinispan)
- [Introduction to OpenCSV](http://www.baeldung.com/opencsv)
- [A Guide to Unirest](http://www.baeldung.com/unirest)

View File

@ -29,12 +29,6 @@
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>${async.http.client.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.beykery/neuroph/2.92 -->
<dependency>
<groupId>org.beykery</groupId>
@ -875,7 +869,6 @@
<kafka.version>2.0.0</kafka.version>
<smooks.version>1.7.0</smooks.version>
<docker.version>3.0.14</docker.version>
<async.http.client.version>2.2.0</async.http.client.version>
<infinispan.version>9.1.5.Final</infinispan.version>
<opencsv.version>4.1</opencsv.version>
<unirest.version>1.4.9</unirest.version>

View File

@ -11,19 +11,19 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
@ -35,7 +35,7 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.1-SNAPSHOT</version>
<version>${commons-beanutils.version}</version>
</dependency>
</dependencies>
@ -71,6 +71,10 @@
<properties>
<commons-compress-version>1.15</commons-compress-version>
<commons-io.version>2.3</commons-io.version>
<commons-collections4.version>4.0</commons-collections4.version>
<commons-lang3.version>3.0</commons-lang3.version>
<commons-beanutils.version>1.9.1</commons-beanutils.version>
</properties>
</project>

View File

@ -19,13 +19,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.1</version>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -34,6 +34,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<assertj-core.version>3.12.1</assertj-core.version>
</properties>
</project>

View File

@ -0,0 +1,3 @@
### Relevant Articles
- [Jest Elasticsearch Java Client](https://www.baeldung.com/elasticsearch-jest)

View File

@ -20,12 +20,16 @@
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>6.3.1</version>
<version>${jest.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<properties>
<jest.version>6.3.1</jest.version>
</properties>
</project>

View File

@ -3,4 +3,5 @@
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
- [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints)
- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many)

View File

@ -31,12 +31,6 @@
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
<scope>test</scope>
</dependency>
<!-- validation -->
<dependency>
<groupId>org.hibernate</groupId>
@ -51,12 +45,12 @@
<dependency>
<groupId>javax.money</groupId>
<artifactId>money-api</artifactId>
<version>1.0.3</version>
<version>${money-api.version}</version>
</dependency>
<dependency>
<groupId>org.javamoney</groupId>
<artifactId>moneta</artifactId>
<version>1.3</version>
<version>${moneta.version}</version>
<type>pom</type>
</dependency>
</dependencies>
@ -76,7 +70,8 @@
<assertj-core.version>3.8.0</assertj-core.version>
<hibernate-validator.version>6.0.16.Final</hibernate-validator.version>
<org.glassfish.javax.el.version>3.0.1-b11</org.glassfish.javax.el.version>
<hsqldb.version>2.3.4</hsqldb.version>
<money-api.version>1.0.3</money-api.version>
<moneta.version>1.3</moneta.version>
</properties>
</project>

View File

@ -10,7 +10,7 @@ import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.service.ServiceRegistry;
import org.junit.After;
import org.junit.AfterClass;
@ -18,6 +18,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.baeldung.hibernate.oneToMany.model.Cart;
import com.baeldung.hibernate.oneToMany.model.Items;
@ -33,9 +34,9 @@ public class HibernateOneToManyAnnotationMainIntegrationTest {
@BeforeClass
public static void beforeTests() {
Configuration configuration = new Configuration().addAnnotatedClass(Cart.class).addAnnotatedClass(Items.class)
.setProperty("hibernate.dialect", HSQLDialect.class.getName())
.setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test")
.setProperty("hibernate.dialect", H2Dialect.class.getName())
.setProperty("hibernate.connection.driver_class", org.h2.Driver.class.getName())
.setProperty("hibernate.connection.url", "jdbc:h2:mem:test")
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
.setProperty("hibernate.hbm2ddl.auto", "update");
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()

View File

@ -19,31 +19,31 @@
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
<version>5.4.0.Final</version>
<version>${hibernate.version}</version>
</dependency>
<!-- Neo4j -->
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-neo4j</artifactId>
<version>5.4.0.Final</version>
<version>${hibernate.version}</version>
</dependency>
<!-- Narayana JTA -->
<dependency>
<groupId>org.jboss.narayana.jta</groupId>
<artifactId>narayana-jta</artifactId>
<version>5.5.23.Final</version>
<version>${narayana-jta.version}</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<version>${fest-assert.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@ -57,4 +57,10 @@
</resource>
</resources>
</build>
<properties>
<hibernate.version>5.4.0.Final</hibernate.version>
<fest-assert.version>1.4</fest-assert.version>
<narayana-jta.version>5.5.23.Final</narayana-jta.version>
</properties>
</project>

View File

@ -33,3 +33,4 @@
- [Hibernate Aggregate Functions](https://www.baeldung.com/hibernate-aggregate-functions)
- [Hibernate Query Plan Cache](https://www.baeldung.com/hibernate-query-plan-cache)
- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception)
- [Enabling Transaction Locks in Spring Data JPA](https://www.baeldung.com/java-jpa-transaction-locks)

View File

@ -60,7 +60,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<version>5.2.2.Final</version>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@ -70,7 +70,7 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.9.5</version>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
@ -91,7 +91,7 @@
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<version>${jaxb-api.version}</version>
</dependency>
</dependencies>
@ -120,6 +120,8 @@
<assertj-core.version>3.8.0</assertj-core.version>
<openjdk-jmh.version>1.21</openjdk-jmh.version>
<geodb.version>0.9</geodb.version>
<byte-buddy.version>1.9.5</byte-buddy.version>
<jaxb-api.version>2.3.0</jaxb-api.version>
</properties>
</project>

View File

@ -34,7 +34,7 @@
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<version>${javax.persistence-api.version}</version>
</dependency>
<!--Runtime JPA implementation-->
@ -108,6 +108,7 @@
<hibernate.version>5.4.0.Final</hibernate.version>
<eclipselink.version>2.7.4-RC1</eclipselink.version>
<postgres.version>42.2.5</postgres.version>
<javax.persistence-api.version>2.2</javax.persistence-api.version>
</properties>
</project>

View File

@ -20,6 +20,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- MongoDB -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,9 @@
package com.baeldung.mongodb.daos;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.baeldung.mongodb.models.Photo;
public interface PhotoRepository extends MongoRepository<Photo, String> {
}

View File

@ -0,0 +1,51 @@
package com.baeldung.mongodb.models;
import org.bson.types.Binary;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "photos")
public class Photo {
@Id
private String id;
private String title;
private Binary image;
public Photo(String title) {
super();
this.title = title;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Binary getImage() {
return image;
}
public void setImage(Binary image) {
this.image = image;
}
@Override
public String toString() {
return "Photo [id=" + id + ", title=" + title + ", image=" + image + "]";
}
}

View File

@ -0,0 +1,39 @@
package com.baeldung.mongodb.models;
import java.io.InputStream;
public class Video {
private String title;
private InputStream stream;
public Video() {
super();
}
public Video(String title) {
super();
this.title = title;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public InputStream getStream() {
return stream;
}
public void setStream(InputStream stream) {
this.stream = stream;
}
@Override
public String toString() {
return "Video [title=" + title + "]";
}
}

View File

@ -0,0 +1,38 @@
package com.baeldung.mongodb.services;
import java.io.IOException;
import java.util.Optional;
import org.bson.BsonBinarySubType;
import org.bson.types.Binary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.mongodb.daos.PhotoRepository;
import com.baeldung.mongodb.models.Photo;
@Service
public class PhotoService {
@Autowired
private PhotoRepository photoRepo;
public Photo getPhoto(String id) {
Optional<Photo> result = photoRepo.findById(id);
return result.isPresent() ? result.get() : null;
}
public String addPhoto(String title, MultipartFile file) {
String id = null;
try {
Photo photo = new Photo(title);
photo.setImage(new Binary(BsonBinarySubType.BINARY, file.getBytes()));
photo = photoRepo.insert(photo);
id = photo.getId();
} catch (IOException e) {
return null;
}
return id;
}
}

View File

@ -0,0 +1,56 @@
package com.baeldung.mongodb.services;
import java.io.IOException;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.gridfs.GridFsOperations;
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.mongodb.models.Video;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.client.gridfs.model.GridFSFile;
@Service
public class VideoService {
@Autowired
private GridFsTemplate gridFsTemplate;
@Autowired
private GridFsOperations operations;
public Video getVideo(String id) {
Video video = null;
GridFSFile file = gridFsTemplate.findOne(new Query(Criteria.where("_id").is(id)));
if (file != null) {
video = new Video();
video.setTitle(file.getMetadata().get("title").toString());
try {
video.setStream(operations.getResource(file).getInputStream());
} catch (IOException e) {
return null;
}
}
return video;
}
public String addVideo(String title, MultipartFile file) {
DBObject metaData = new BasicDBObject();
metaData.put("type", "video");
metaData.put("title", title);
ObjectId id;
try {
id = gridFsTemplate.store(file.getInputStream(), file.getName(), file.getContentType(), metaData);
} catch (IOException e) {
return null;
}
return id.toString();
}
}

View File

@ -0,0 +1,50 @@
package com.baeldung.mongodb.web;
import java.util.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.mongodb.models.Photo;
import com.baeldung.mongodb.services.PhotoService;
@Controller
public class PhotoController {
@Autowired
private PhotoService photoService;
@GetMapping("/photos/{id}")
public String getPhoto(@PathVariable String id, Model model) {
Photo photo = photoService.getPhoto(id);
if (photo != null) {
model.addAttribute("title", photo.getTitle());
model.addAttribute("image", Base64.getEncoder().encodeToString(photo.getImage().getData()));
return "photos";
}
model.addAttribute("message", "Photo not found");
return "index";
}
@GetMapping("/photos/upload")
public String uploadPhoto(Model model) {
model.addAttribute("message", "hello");
return "uploadPhoto";
}
@PostMapping("/photos/add")
public String addPhoto(@RequestParam("title") String title, @RequestParam("image") MultipartFile image, Model model) {
String id = photoService.addPhoto(title, image);
if (id == null) {
model.addAttribute("message", "Error Occurred");
return "index";
}
return "redirect:/photos/" + id;
}
}

View File

@ -0,0 +1,67 @@
package com.baeldung.mongodb.web;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.mongodb.models.Video;
import com.baeldung.mongodb.services.VideoService;
@Controller
public class VideoController {
@Autowired
private VideoService videoService;
@GetMapping("/videos/{id}")
public String getVideo(@PathVariable String id, Model model) {
Video video = videoService.getVideo(id);
if (video != null) {
model.addAttribute("title", video.getTitle());
model.addAttribute("url", "/videos/stream/" + id);
return "videos";
}
model.addAttribute("message", "Video not found");
return "index";
}
@GetMapping("/videos/stream/{id}")
public void streamVideo(@PathVariable String id, HttpServletResponse response) {
Video video = videoService.getVideo(id);
if (video != null) {
try {
FileCopyUtils.copy(video.getStream(), response.getOutputStream());
} catch (IOException e) {
response.setStatus(500);
}
} else {
response.setStatus(404);
}
}
@GetMapping("/videos/upload")
public String uploadVideo(Model model) {
model.addAttribute("message", "hello");
return "uploadVideo";
}
@PostMapping("/videos/add")
public String addVideo(@RequestParam("title") String title, @RequestParam("file") MultipartFile file, Model model) {
String id = videoService.addVideo(title, file);
if (id == null) {
model.addAttribute("message", "Error Occurred");
return "index";
}
return "redirect:/videos/" + id;
}
}

View File

@ -1,8 +1,13 @@
spring.application.name=spring-boot-persistence
server.port=${PORT:0}
server.port=8082
#spring boot mongodb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=springboot-mongo
spring.thymeleaf.cache=false
spring.servlet.multipart.max-file-size=256MB
spring.servlet.multipart.max-request-size=256MB
spring.servlet.multipart.enabled=true

View File

@ -0,0 +1,14 @@
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload Files MongoDB</title>
</head>
<body>
<h1>Home Page</h1>
<div th:if="${message != null}" th:text="${message}">Message</div>
<br/>
<a href="/photos/upload">Upload new Photo</a>
<br/><br/>
<a href="/videos/upload">Upload new Video</a>
</body>
</html>

View File

@ -0,0 +1,10 @@
<html xmlns:th="https://www.thymeleaf.org">
<body>
<h1>View Photo</h1>
Title: <span th:text="${title}">name</span>
<br/>
<img alt="sample" th:src="*{'data:image/png;base64,'+image}" width="200"/>
<br/> <br/>
<a href="/">Back to home page</a>
</body>
</html>

View File

@ -0,0 +1,15 @@
<html xmlns:th="https://www.thymeleaf.org">
<body>
<h1>Upload new Photo</h1>
<form method="POST" action="/photos/add" enctype="multipart/form-data">
Title:<input type="text" name="title" />
<br/>
Image:<input type="file" name="image" accept="image/*" />
<br/>
<br/>
<input type="submit" value="Upload" />
</form>
</body>
</html>

View File

@ -0,0 +1,15 @@
<html xmlns:th="https://www.thymeleaf.org">
<body>
<h1>Upload new Video</h1>
<form method="POST" action="/videos/add" enctype="multipart/form-data">
Title:<input type="text" name="title" />
<br/>
Video:<input type="file" name="file" accept="video/*" />
<br/>
<br/>
<input type="submit" value="Upload" />
</form>
</body>
</html>

View File

@ -0,0 +1,15 @@
<html xmlns:th="https://www.thymeleaf.org">
<body>
<h1>View Video</h1>
Title: <span th:text="${title}">title</span>
<br/>
<br/>
<video width="400" controls>
<source th:src="${url}" />
</video>
<br/> <br/>
<a href="/">Back to home page</a>
</body>
</html>

View File

@ -29,7 +29,7 @@
<dependency>
<groupId>net.ttddyy</groupId>
<artifactId>datasource-proxy</artifactId>
<version>1.4.1</version>
<version>${datasource-proxy.version}</version>
</dependency>
<dependency>
@ -42,4 +42,8 @@
<artifactId>spring-oxm</artifactId>
</dependency>
</dependencies>
<properties>
<datasource-proxy.version>1.4.1</datasource-proxy.version>
</properties>
</project>

View File

@ -37,14 +37,14 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.10.6</version>
<version>${testcontainers.postgresql.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
<version>${postgresql.version}</version>
</dependency>
<!-- Test containers only dependencies -->
@ -66,7 +66,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
<version>${guava.version}</version>
</dependency>
<!-- JUnit Jupiter dependencies -->
@ -92,6 +92,9 @@
<properties>
<start-class>com.baeldung.boot.Application</start-class>
<testcontainers.postgresql.version>1.10.6</testcontainers.postgresql.version>
<postgresql.version>42.2.5</postgresql.version>
<guava.version>21.0</guava.version>
</properties>
</project>

View File

@ -506,6 +506,7 @@
<module>libraries-primitive</module>
<module>libraries-security</module>
<module>libraries-server</module>
<module>libraries-http</module>
<module>linkrest</module>
<module>logging-modules</module>
<module>lombok</module>
@ -1185,6 +1186,7 @@
<module>libraries-apache-commons</module>
<module>libraries-security</module>
<module>libraries-server</module>
<module>libraries-http</module>
<module>linkrest</module>
<module>logging-modules</module>
<module>lombok</module>
@ -1552,6 +1554,7 @@
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-cli.version>1.4</commons-cli.version>
<maven-war-plugin.version>3.0.0</maven-war-plugin.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>

View File

@ -6,3 +6,4 @@
- [Ratpack with Hystrix](http://www.baeldung.com/ratpack-hystrix)
- [Ratpack HTTP Client](https://www.baeldung.com/ratpack-http-client)
- [Ratpack with RxJava](https://www.baeldung.com/ratpack-rxjava)
- [Ratpack with Groovy](https://www.baeldung.com/ratpack-groovy)

View File

@ -0,0 +1,8 @@
package com.baeldung.components;
import org.springframework.stereotype.Component;
@Component
public class AccountService {
}

View File

@ -0,0 +1,16 @@
package com.baeldung.components;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UserService {
@Autowired
private AccountService accountService;
public AccountService getAccountService() {
return accountService;
}
}

View File

@ -0,0 +1,15 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config />
<context:component-scan base-package="com.baeldung.components" />
<bean id="accountService" class="com.baeldung.components.AccountService"></bean>
<bean id="userService" class="com.baeldung.components.UserService">
<!-- If we have <context:annotation-config/> on top, then we don't need to set the properties(dependencies) in XML. -->
<!-- <property name="accountService" ref="accountService"></property> -->
</bean>
</beans>

View File

@ -0,0 +1,23 @@
package com.baeldung;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.baeldung.components.AccountService;
import com.baeldung.components.UserService;
public class SpringXMLConfigurationIntegrationTest {
@Test
public void givenContextAnnotationConfigOrContextComponentScan_whenDependenciesAndBeansAnnotated_thenNoXMLNeeded() {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:beans.xml");
UserService userService = context.getBean(UserService.class);
AccountService accountService = context.getBean(AccountService.class);
Assert.assertNotNull(userService);
Assert.assertNotNull(accountService);
Assert.assertNotNull(userService.getAccountService());
}
}

View File

@ -4,3 +4,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
- [Guide to ApplicationContextRunner in Spring Boot](https://www.baeldung.com/spring-boot-context-runner)

View File

@ -40,7 +40,7 @@
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.7</version>
<version>${javax.faces.version}</version>
</dependency>
<!--Test -->
@ -108,6 +108,7 @@
<spring.fox.version>2.9.2</spring.fox.version>
<!-- ROME for RSS -->
<rome.version>1.10.0</rome.version>
<javax.faces.version>2.3.7</javax.faces.version>
<start-class>com.baeldung.springbootmvc.SpringBootMvcApplication</start-class>
</properties>

View File

@ -0,0 +1,3 @@
### Relevant Articles
- [The Spring Boot Starter Parent](https://www.baeldung.com/spring-boot-starter-parent)

View File

@ -0,0 +1,3 @@
### Relevant Articles
- [Lazy Initialization in Spring Boot 2](https://www.baeldung.com/spring-boot-lazy-initialization)

View File

@ -37,3 +37,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation)
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
- [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application)
- [Guide to @EnableConfigurationProperties](https://www.baeldung.com/spring-enable-config-properties)

View File

@ -0,0 +1,30 @@
package com.baeldung.properties.conversion;
public class Employee {
private String name;
private double salary;
public Employee(String name, double salary) {
super();
this.name = name;
this.salary = salary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}

View File

@ -0,0 +1,16 @@
package com.baeldung.properties.conversion;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
@Component
@ConfigurationPropertiesBinding
public class EmployeeConverter implements Converter<String, Employee> {
@Override
public Employee convert(String from) {
String[] data = from.split(",");
return new Employee(data[0], Double.parseDouble(data[1]));
}
}

View File

@ -0,0 +1,14 @@
package com.baeldung.properties.conversion;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackageClasses = { PropertyConversion.class, EmployeeConverter.class })
public class PropertiesConversionApplication {
public static void main(String[] args) {
SpringApplication.run(PropertiesConversionApplication.class, args);
}
}

View File

@ -0,0 +1,92 @@
package com.baeldung.properties.conversion;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
@Configuration
@PropertySource("classpath:conversion.properties")
@ConfigurationProperties(prefix = "conversion")
public class PropertyConversion {
private Duration timeInDefaultUnit;
private Duration timeInNano;
@DurationUnit(ChronoUnit.DAYS)
private Duration timeInDays;
private DataSize sizeInDefaultUnit;
private DataSize sizeInGB;
@DataSizeUnit(DataUnit.TERABYTES)
private DataSize sizeInTB;
private Employee employee;
// Getters and setters
public Duration getTimeInDefaultUnit() {
return timeInDefaultUnit;
}
public void setTimeInDefaultUnit(Duration timeInDefaultUnit) {
this.timeInDefaultUnit = timeInDefaultUnit;
}
public Duration getTimeInNano() {
return timeInNano;
}
public void setTimeInNano(Duration timeInNano) {
this.timeInNano = timeInNano;
}
public Duration getTimeInDays() {
return timeInDays;
}
public void setTimeInDays(Duration timeInDays) {
this.timeInDays = timeInDays;
}
public DataSize getSizeInDefaultUnit() {
return sizeInDefaultUnit;
}
public void setSizeInDefaultUnit(DataSize sizeInDefaultUnit) {
this.sizeInDefaultUnit = sizeInDefaultUnit;
}
public DataSize getSizeInGB() {
return sizeInGB;
}
public void setSizeInGB(DataSize sizeInGB) {
this.sizeInGB = sizeInGB;
}
public DataSize getSizeInTB() {
return sizeInTB;
}
public void setSizeInTB(DataSize sizeInTB) {
this.sizeInTB = sizeInTB;
}
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
}

View File

@ -0,0 +1,46 @@
package com.baeldung.properties.conversion;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.unit.DataSize;
import com.baeldung.properties.conversion.PropertiesConversionApplication;
import com.baeldung.properties.conversion.PropertyConversion;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = PropertiesConversionApplication.class)
@TestPropertySource("classpath:conversion.properties")
public class PropertiesConversionIntegrationTest {
@Autowired
private PropertyConversion properties;
@Test
public void whenUseTimeUnitPropertyConversion_thenSuccess() throws Exception {
assertEquals(Duration.ofMillis(10), properties.getTimeInDefaultUnit());
assertEquals(Duration.ofNanos(9), properties.getTimeInNano());
assertEquals(Duration.ofDays(2), properties.getTimeInDays());
}
@Test
public void whenUseDataSizePropertyConversion_thenSuccess() throws Exception {
assertEquals(DataSize.ofBytes(300), properties.getSizeInDefaultUnit());
assertEquals(DataSize.ofGigabytes(2), properties.getSizeInGB());
assertEquals(DataSize.ofTerabytes(4), properties.getSizeInTB());
}
@Test
public void whenUseCustomPropertyConverter_thenSuccess() throws Exception {
assertEquals("john", properties.getEmployee().getName());
assertEquals(2000.0, properties.getEmployee().getSalary());
}
}

View File

@ -0,0 +1,11 @@
###### time unit
conversion.timeInDefaultUnit=10
conversion.timeInNano=9ns
conversion.timeInDays=2
###### data size
conversion.sizeInDefaultUnit=300
conversion.sizeInGB=2GB
conversion.sizeInTB=4
conversion.employee=john,2000

View File

@ -29,7 +29,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-function-web</artifactId>
<version>1.0.1.RELEASE</version>
<version>${spring-cloud-function.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
@ -40,7 +40,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
<version>${aws-lambda-java-core.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -87,6 +87,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud-function.version>1.0.1.RELEASE</spring-cloud-function.version>
<aws-lambda-events.version>2.0.2</aws-lambda-events.version>
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<spring-boot.version>2.0.4.RELEASE</spring-boot.version>
</properties>

View File

@ -82,7 +82,7 @@
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
<version>${javax.el.version}</version>
</dependency>
<dependency>
@ -131,12 +131,11 @@
<hibernate-validator.version>6.0.10.Final</hibernate-validator.version>
<jstl.version>1.2</jstl.version>
<javax.servlet.version>3.1.0</javax.servlet.version>
<jackson.version>2.9.6</jackson.version>
<javax.el.version>3.0.1-b08</javax.el.version>
<!-- util -->
<guava.version>19.0</guava.version>
<commons-lang3.version>3.5</commons-lang3.version>
<commons-io.version>2.5</commons-io.version>
<geoip2.version>2.8.0</geoip2.version>
<!-- Maven plugins -->

View File

@ -6,7 +6,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping)
- [Returning Custom Status Codes from Spring Controllers](http://www.baeldung.com/spring-mvc-controller-custom-http-status-code)
- [A Guide to OkHttp](http://www.baeldung.com/guide-to-okhttp)
- [Binary Data Formats in a Spring REST API](http://www.baeldung.com/spring-rest-api-with-binary-data-formats)
- [Guide to UriComponentsBuilder in Spring](http://www.baeldung.com/spring-uricomponentsbuilder)
- [Introduction to FindBugs](http://www.baeldung.com/intro-to-findbugs)

View File

@ -93,13 +93,6 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${com.squareup.okhttp3.version}</version>
</dependency>
<!-- test scoped -->
<dependency>
<groupId>org.hamcrest</groupId>
@ -280,8 +273,6 @@
<findbugs-maven-plugin.version>3.0.4</findbugs-maven-plugin.version>
<checkstyle-maven-plugin.version>3.0.0</checkstyle-maven-plugin.version>
<dependency.locations.enabled>false</dependency.locations.enabled>
<!-- okhttp -->
<com.squareup.okhttp3.version>3.4.1</com.squareup.okhttp3.version>
<json.path.version>2.2.0</json.path.version>
<pact.version>3.5.11</pact.version>

View File

@ -10,3 +10,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Configure a RestTemplate with RestTemplateBuilder](http://www.baeldung.com/spring-rest-template-builder)
- [Mocking a RestTemplate in Spring](https://www.baeldung.com/spring-mock-rest-template)
- [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json)
- [Download a Large File Through a Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-download-large-file)

View File

@ -8,10 +8,10 @@
<packaging>war</packaging>
<parent>
<artifactId>parent-boot-2</artifactId>
<groupId>com.baeldung</groupId>
<artifactId>parent-spring-4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-spring-4</relativePath>
<relativePath>../parent-boot-2</relativePath>
</parent>
<dependencies>
@ -19,74 +19,26 @@
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<!-- web -->
@ -94,14 +46,12 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
<scope>runtime</scope>
</dependency>
@ -117,7 +67,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.10.RELEASE</version>
<scope>test</scope>
</dependency>
@ -166,9 +115,6 @@
</build>
<properties>
<!-- Spring -->
<org.springframework.security.version>4.2.6.RELEASE</org.springframework.security.version>
<!-- various -->
<codahale.metrics.version>3.0.2</codahale.metrics.version>

View File

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

View File

@ -5,13 +5,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;
import org.springframework.web.servlet.view.JstlView;
@EnableWebMvc
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {
public class MvcConfig implements WebMvcConfigurer {
public MvcConfig() {
super();
@ -21,7 +21,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/anonymous.html");

View File

@ -8,6 +8,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.session.HttpSessionEventPublisher;
@ -24,9 +26,9 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth.inMemoryAuthentication()
.withUser("user1").password("user1Pass").roles("USER")
.withUser("user1").password(passwordEncoder().encode("user1Pass")).roles("USER")
.and()
.withUser("admin1").password("admin1Pass").roles("ADMIN");
.withUser("admin1").password(passwordEncoder().encode("admin1Pass")).roles("ADMIN");
// @formatter:on
}
@ -69,4 +71,9 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
return new HttpSessionEventPublisher();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}

View File

@ -2,9 +2,9 @@
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"
http://www.springframework.org/schema/beans/spring-beans.xsd"
>
<http create-session="always" use-expressions="true">

Some files were not shown because too many files have changed in this diff Show More