Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f36035a22a
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>apache-poi-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>apache-poi-3</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<poi.version>5.2.3</poi.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,70 @@
|
|||
package com.baeldung.poi.excel.expandcolumn;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ExpandColumnUnitTest {
|
||||
|
||||
private Workbook workbook;
|
||||
private Sheet sheet;
|
||||
|
||||
@BeforeEach
|
||||
void prepareSpreadsheet() {
|
||||
workbook = new XSSFWorkbook();
|
||||
sheet = workbook.createSheet();
|
||||
|
||||
Row headerRow = sheet.createRow(0);
|
||||
Cell headerCell1 = headerRow.createCell(0);
|
||||
headerCell1.setCellValue("Full Name");
|
||||
Cell headerCell2 = headerRow.createCell(1);
|
||||
headerCell2.setCellValue("Abbreviation");
|
||||
|
||||
Row dataRow = sheet.createRow(1);
|
||||
Cell dataCell1 = dataRow.createCell(0);
|
||||
dataCell1.setCellValue("Java Virtual Machine");
|
||||
Cell dataCell2 = dataRow.createCell(1);
|
||||
dataCell2.setCellValue("JVM");
|
||||
|
||||
dataRow = sheet.createRow(2);
|
||||
dataCell1 = dataRow.createCell(0);
|
||||
dataCell1.setCellValue("Java Runtime Environment");
|
||||
dataCell2 = dataRow.createCell(1);
|
||||
dataCell2.setCellValue("JRE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenSetColumnWidth_thenColumnSetToTheSpecifiedWidth() {
|
||||
|
||||
Row row = sheet.getRow(2);
|
||||
String cellValue = row.getCell(0).getStringCellValue();
|
||||
int targetWidth = cellValue.length() * 256;
|
||||
|
||||
sheet.setColumnWidth(0, targetWidth);
|
||||
|
||||
assertEquals(targetWidth, sheet.getColumnWidth(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenAutoSizeColumn_thenColumnExpands() {
|
||||
|
||||
int originalWidth = sheet.getColumnWidth(0);
|
||||
|
||||
sheet.autoSizeColumn(0);
|
||||
|
||||
assertThat(sheet.getColumnWidth(0)).isGreaterThan(originalWidth);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanup() throws IOException {
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.baeldung.mergeandremoveduplicate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class MergeArraysAndRemoveDuplicate {
|
||||
|
||||
public static int[] removeDuplicateOnSortedArray(int[] arr) {
|
||||
// Initialize a new array to store unique elements
|
||||
int[] uniqueArray = new int[arr.length];
|
||||
uniqueArray[0] = arr[0];
|
||||
int uniqueCount = 1;
|
||||
|
||||
// Iterate through the sorted array to remove duplicates
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
if (arr[i] != arr[i - 1]) {
|
||||
uniqueArray[uniqueCount] = arr[i];
|
||||
uniqueCount++;
|
||||
}
|
||||
}
|
||||
int[] truncatedArray = new int[uniqueCount];
|
||||
System.arraycopy(uniqueArray, 0, truncatedArray, 0, uniqueCount);
|
||||
return truncatedArray;
|
||||
}
|
||||
|
||||
public static int[] mergeAndRemoveDuplicatesUsingStream(int[] arr1, int[] arr2) {
|
||||
Stream<Integer> s1 = Arrays.stream(arr1).boxed();
|
||||
Stream<Integer> s2 = Arrays.stream(arr2).boxed();
|
||||
return Stream.concat(s1, s2)
|
||||
.distinct()
|
||||
.mapToInt(Integer::intValue)
|
||||
.toArray();
|
||||
}
|
||||
|
||||
public static int[] mergeAndRemoveDuplicatesUsingSet(int[] arr1, int[] arr2) {
|
||||
int[] mergedArr = mergeArrays(arr1, arr2);
|
||||
Set<Integer> uniqueInts = new HashSet<>();
|
||||
|
||||
for (int el : mergedArr) {
|
||||
uniqueInts.add(el);
|
||||
}
|
||||
|
||||
return getArrayFromSet(uniqueInts);
|
||||
}
|
||||
|
||||
private static int[] getArrayFromSet(Set<Integer> set) {
|
||||
int[] mergedArrWithoutDuplicated = new int[set.size()];
|
||||
int i = 0;
|
||||
for (Integer el: set) {
|
||||
mergedArrWithoutDuplicated[i] = el;
|
||||
i++;
|
||||
}
|
||||
return mergedArrWithoutDuplicated;
|
||||
}
|
||||
|
||||
public static int[] mergeAndRemoveDuplicates(int[] arr1, int[] arr2) {
|
||||
return removeDuplicate(mergeArrays(arr1, arr2));
|
||||
}
|
||||
|
||||
public static int[] mergeAndRemoveDuplicatesOnSortedArray(int[] arr1, int[] arr2) {
|
||||
return removeDuplicateOnSortedArray(mergeArrays(arr1, arr2));
|
||||
}
|
||||
|
||||
private static int[] mergeArrays(int[] arr1, int[] arr2) {
|
||||
int[] mergedArrays = new int[arr1.length + arr2.length];
|
||||
System.arraycopy(arr1, 0, mergedArrays, 0, arr1.length);
|
||||
System.arraycopy(arr2, 0, mergedArrays, arr1.length, arr2.length);
|
||||
|
||||
return mergedArrays;
|
||||
}
|
||||
private static int[] removeDuplicate(int[] arr) {
|
||||
int[] withoutDuplicates = new int[arr.length];
|
||||
int i = 0;
|
||||
|
||||
for(int element : arr) {
|
||||
if(!isElementPresent(withoutDuplicates, element)) {
|
||||
withoutDuplicates[i] = element;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
int[] truncatedArray = new int[i];
|
||||
System.arraycopy(withoutDuplicates, 0, truncatedArray, 0, i);
|
||||
return truncatedArray;
|
||||
}
|
||||
|
||||
private static boolean isElementPresent(int[] arr, int element) {
|
||||
for(int el : arr) {
|
||||
if(el == element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.baeldung.mergeandremoveduplicate;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public class MergeArraysAndRemoveDuplicateUnitTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MergeArraysAndRemoveDuplicateUnitTest.class);
|
||||
|
||||
private static String getCommaDelimited(int[] arr) {
|
||||
return Arrays.stream(arr)
|
||||
.mapToObj(Integer::toString)
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNoLibraryAndUnSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() {
|
||||
int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9};
|
||||
int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17};
|
||||
int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17};
|
||||
|
||||
int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicates(arr1, arr2);
|
||||
|
||||
//merged array maintains the order of the elements in the arrays
|
||||
assertArrayEquals(expectedArr, mergedArr);
|
||||
|
||||
logger.info(getCommaDelimited(mergedArr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNoLibraryAndSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() {
|
||||
int[] arr1 = {1, 2, 3, 4, 5, 5, 6, 7, 7, 8};
|
||||
int[] arr2 = {8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17};
|
||||
int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
|
||||
int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesOnSortedArray(arr1, arr2);
|
||||
|
||||
assertArrayEquals(expectedArr, mergedArr);
|
||||
|
||||
logger.info(getCommaDelimited(mergedArr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSet_whenArr1andArr2_thenMergeAndRemoveDuplicates() {
|
||||
int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9};
|
||||
int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17};
|
||||
int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
|
||||
int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingSet(arr1, arr2);
|
||||
|
||||
assertArrayEquals(expectedArr, mergedArr);
|
||||
|
||||
logger.info(getCommaDelimited(mergedArr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStream_whenArr1andArr2_thenMergeAndRemoveDuplicates() {
|
||||
int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9};
|
||||
int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17};
|
||||
int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17};
|
||||
|
||||
int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingStream(arr1, arr2);
|
||||
|
||||
assertArrayEquals(expectedArr, mergedArr);
|
||||
|
||||
logger.info(getCommaDelimited(mergedArr));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?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>core-java-arrays-operations-advanced-2</artifactId>
|
||||
<name>core-java-arrays-operations-advanced-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -62,4 +62,4 @@ public class MiddleOfArray {
|
|||
return array[mid];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,4 +86,4 @@ public class MiddleOfArrayUnitTest {
|
|||
MiddleOfArray middleOfArray = new MiddleOfArray();
|
||||
Assert.assertEquals(expectMedian, middleOfArray.medianOfArray(array, 0, 100));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ public class IdentityHashMapDemonstrator {
|
|||
}
|
||||
}
|
||||
|
||||
private static class Book {
|
||||
static class Book {
|
||||
String title;
|
||||
int year;
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.baeldung.map.identity;
|
||||
|
||||
import com.baeldung.map.identity.IdentityHashMapDemonstrator.Book;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
@ -18,4 +21,44 @@ public class IdentityHashMapDemonstratorUnitTest {
|
|||
assertEquals("Fantasy", identityHashMap.get("genre"));
|
||||
assertEquals("Drama", identityHashMap.get(newGenreKey));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(max = JRE.JAVA_19)
|
||||
public void removeEntryComparingValueByEquality() {
|
||||
Book book = new Book("A Passage to India", 1924);
|
||||
IdentityHashMap<Book, String> identityHashMap = new IdentityHashMap<>(10);
|
||||
identityHashMap.put(book, "A great work of fiction");
|
||||
identityHashMap.remove(book, new String("A great work of fiction"));
|
||||
assertEquals(null, identityHashMap.get(book));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(max = JRE.JAVA_19)
|
||||
public void replaceEntryComparingValueByEquality() {
|
||||
Book book = new Book("A Passage to India", 1924);
|
||||
IdentityHashMap<Book, String> identityHashMap = new IdentityHashMap<>(10);
|
||||
identityHashMap.put(book, "A great work of fiction");
|
||||
identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books");
|
||||
assertEquals("One of the greatest books", identityHashMap.get(book));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(min = JRE.JAVA_20)
|
||||
public void dontRemoveEntryComparingValueByEquality() {
|
||||
Book book = new Book("A Passage to India", 1924);
|
||||
IdentityHashMap<Book, String> identityHashMap = new IdentityHashMap<>(10);
|
||||
identityHashMap.put(book, "A great work of fiction");
|
||||
identityHashMap.remove(book, new String("A great work of fiction"));
|
||||
assertEquals("A great work of fiction", identityHashMap.get(book));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(min = JRE.JAVA_20)
|
||||
public void dontReplaceEntryComparingValueByEquality() {
|
||||
Book book = new Book("A Passage to India", 1924);
|
||||
IdentityHashMap<Book, String> identityHashMap = new IdentityHashMap<>(10);
|
||||
identityHashMap.put(book, "A great work of fiction");
|
||||
identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books");
|
||||
assertEquals("A great work of fiction", identityHashMap.get(book));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.apache.tika.mime.MimeTypeException;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.j256.simplemagic.ContentInfo;
|
||||
import com.j256.simplemagic.ContentType;
|
||||
|
||||
public class ExtensionFromMimeTypeUnitTest {
|
||||
private static final String IMAGE_JPEG_MIME_TYPE = "image/jpeg";
|
||||
|
@ -39,8 +39,7 @@ public class ExtensionFromMimeTypeUnitTest {
|
|||
@Test
|
||||
public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() {
|
||||
List<String> expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe");
|
||||
ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true);
|
||||
String[] detectedExtensions = contentInfo.getFileExtensions();
|
||||
String[] detectedExtensions = ContentType.fromMimeType(IMAGE_JPEG_MIME_TYPE).getFileExtensions();
|
||||
assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class EchoIntegrationTest {
|
|||
|
||||
Executors.newSingleThreadExecutor()
|
||||
.submit(() -> new EchoServer().start(port));
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
private EchoClient client = new EchoClient();
|
||||
|
|
|
@ -27,7 +27,7 @@ public class GreetServerIntegrationTest {
|
|||
|
||||
Executors.newSingleThreadExecutor()
|
||||
.submit(() -> new GreetServer().start(port));
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SocketEchoMultiIntegrationTest {
|
|||
s.close();
|
||||
|
||||
Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(port));
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
<module>core-java-arrays-convert</module>
|
||||
<module>core-java-arrays-operations-basic</module>
|
||||
<module>core-java-arrays-operations-advanced</module>
|
||||
<module>core-java-arrays-operations-advanced-2</module>
|
||||
<module>core-java-booleans</module>
|
||||
<module>core-java-char</module>
|
||||
<module>core-java-collections</module>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -816,6 +816,7 @@
|
|||
<module>apache-olingo</module>
|
||||
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-poi-3</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
|
||||
|
@ -1089,6 +1090,7 @@
|
|||
<module>apache-olingo</module>
|
||||
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-poi-3</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@
|
|||
<description>This is simple boot application demonstrating a custom auto-configuration</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring-boot-modules</groupId>
|
||||
<artifactId>spring-boot-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -66,6 +67,13 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.autoconfiguration.example.AutoconfigurationApplication</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ package com.baeldung.autoconfiguration;
|
|||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
||||
|
@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -31,7 +30,9 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@Configuration
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass(DataSource.class)
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
@PropertySource("classpath:mysql.properties")
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.baeldung.autoconfiguration.annotationprocessor;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "database")
|
||||
public class DatabaseProperties {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.baeldung.autoconfiguration.example;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class MyUser {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.baeldung.autoconfiguration.MySQLAutoconfiguration
|
|
@ -0,0 +1 @@
|
|||
com.baeldung.autoconfiguration.MySQLAutoconfiguration
|
|
@ -1,5 +1,5 @@
|
|||
usemysql=local
|
||||
|
||||
mysql-hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
|
||||
mysql-hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||
mysql-hibernate.show_sql=true
|
||||
mysql-hibernate.hbm2ddl.auto=create-drop
|
|
@ -27,7 +27,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>${jasypt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -46,15 +46,7 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestone</id>
|
||||
<name>Spring Milestone</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<jasypt.version>2.0.0</jasypt.version>
|
||||
<jasypt.version>3.0.5</jasypt.version>
|
||||
</properties>
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
## Relevant Articles
|
|
@ -0,0 +1,56 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<artifactId>springbootsslbundles</artifactId>
|
||||
<name>spring-boot-ssl-bundles</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Module for showing usage of SSL Bundles</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5-fluent</artifactId>
|
||||
<version>${apache.client5.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<apache.client5.version>5.0.3</apache.client5.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
package com.baeldung.springbootsslbundles;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.boot.ssl.SslBundles;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SSLBundlesApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SSLBundlesApp.class, args);
|
||||
}
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder, SslBundles sslBundles) {
|
||||
return restTemplateBuilder.setSslBundle(sslBundles.getBundle("secure-service")).build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.baeldung.springbootsslbundles;
|
||||
|
||||
import org.apache.hc.client5.http.classic.HttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
|
||||
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
|
||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ssl.NoSuchSslBundleException;
|
||||
import org.springframework.boot.ssl.SslBundle;
|
||||
import org.springframework.boot.ssl.SslBundles;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
@Component
|
||||
public class SecureRestTemplateConfig {
|
||||
private final SSLContext sslContext;
|
||||
|
||||
@Autowired
|
||||
public SecureRestTemplateConfig(SslBundles sslBundles) throws NoSuchSslBundleException {
|
||||
SslBundle sslBundle = sslBundles.getBundle("secure-service");
|
||||
this.sslContext = sslBundle.createSslContext();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate secureRestTemplate() {
|
||||
final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create().setSslContext(this.sslContext).build();
|
||||
final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create().setSSLSocketFactory(sslSocketFactory).build();
|
||||
HttpClient httpClient = HttpClients.custom().setConnectionManager(cm).evictExpiredConnections().build();
|
||||
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.baeldung.springbootsslbundles;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
public class SecureServiceRestApi {
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
public SecureServiceRestApi(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public String fetchData(String dataId) {
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
"https://secure-service.com/api/data/{id}",
|
||||
HttpMethod.GET,
|
||||
null,
|
||||
String.class,
|
||||
dataId
|
||||
);
|
||||
return response.getBody();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
spring:
|
||||
ssl:
|
||||
bundle:
|
||||
jks:
|
||||
secure-service:
|
||||
key:
|
||||
alias: "secure-service"
|
||||
keystore:
|
||||
location: "classpath:keystore.p12"
|
||||
password: "FooBar"
|
||||
type: "PKCS12"
|
|
@ -0,0 +1,31 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIFazCCA1OgAwIBAgIUCJcVMwyhLy/ln+ENMXbSWcsO0aswDQYJKoZIhvcNAQEL
|
||||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
||||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMzA5MDUxNjAyMzdaFw0yNDA5
|
||||
MDQxNjAyMzdaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
|
||||
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB
|
||||
AQUAA4ICDwAwggIKAoICAQDMNn+ZmPfR4FUyG6PVGBB2rOAnIHqFqYMVyDUOtZja
|
||||
9CxpgbQjHRwwWaUWcYzLPOsvN/tMC8BazAFHSI2KIeNKgjAesv9JTumqgFXdOmw8
|
||||
KT7a9C1IQXnCMhlbp9J7c7CLvjAvZvZBghxFLc7xBZo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OB1VLRxAPonr9Iqk358EJ1T22uEcMdKE+sMnCBjw2fYIYRfjhGN+m6U6sb4MrF
|
||||
zFUI6qB7W7T/5iukiRb4pLQ0OGgKOwYxpZoxcB3Ldjo5x58uKNOTNJ5zEJ8HUofA
|
||||
BNfty10D3m3DlSyYbf7m1UUM0jj2l83LBGQzhGGUZgCnCsMczLrj64Gvf2iLGmCF
|
||||
gu5zrxL01dptBkvTsYJwYBA67BBS4FcgYNMGx3m1uPsVUUIguJxufXWYfbub74QV
|
||||
a1SH1NjO8HR3DLDU+S92tyTKWOUzJ5qOegEsR2cutVRzDuVTsFy7kayuNv/uLRrG
|
||||
3P2HnUo8PG/nmysReBk6CGycUiDTt55DoPYGoQ5l19xTlkIt7ulNg7yX5pwFMeE=
|
||||
-----END CERTIFICATE-----
|
|
@ -0,0 +1,54 @@
|
|||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIJpDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIblni8xi+83QCAggA
|
||||
MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJSRFMcxzIKiBIIJUEqyZcVQEBL1
|
||||
6jkeo5TGxVwolLnCNpEuj8UwLoK5Z2N5oVwSPzD5rMYuPg6OXXWk6zReaaKBkRR2
|
||||
vlpkckA4o+aSXfzvEXYGd+rZ3EeIK43zquIBjymlcN++FbEYOtAY1SoQm7FtyvdN
|
||||
4QW7MOONUJcnN3EgRSRic2CCa0k6NSREfrBWaa+OcYB4C/JEuA2xgkCUw8bCcos6
|
||||
mksoF6mZDQearirNankMDR7gLQt9pdK7S55T4sCrFpL072s3k7lV0WtvTE/CQ8Wu
|
||||
pdBKVPvpvkR1S9n3ajGMWVYBjkRuD0MMn1eGMW6t3mRI8+C15zTp9DjzySJTMzUm
|
||||
C3l/m9VQBFewuHLziJFylqy7kgxrUUe39FShHYkJZDprZSYE33Lz67o8oHpLkkIh
|
||||
YccDm2bgqIbKfslbAIXD4BKq0QO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
||||
OLxrKjk7dZ+Hmy60zPjgYkHyvOdZRUKfIhZrpCM5Al/xKUqhR6rPtr2U7lkHw9zT
|
||||
gsK6rxXfvmJjIzSFBQzBah8K9rYzk/DScXMQ+3XY7fu6r2LTnfWxCKYhX/2eEoXW
|
||||
/+t0HsRNoGCLB9g8sDAt2tDbjOsGRIdtfQ28Q56Pi91+IlGE5/n4iJ/bws5F1MXB
|
||||
amG44iYYNPHUnkr3YsQeCiyh/1GgiLbIi3P6ZVJ5vG1a5oPGNolsABMZ5HZzd/aD
|
||||
LgZDFjIMDzL5WaP2xhfnTjQsaowpulLE0/7mrc5KnfKxwdlDmLGjLIRsa5fXbL6W
|
||||
rqezhAkgRrGRhnljMnCgZGpkHMtZN3S0u78/u17FvtlbyDFOev1y9cpvMmp/RAP3
|
||||
OXp7Wo3JELz/7aMkmVt6a++j9hxuX0vas6PPCoM0PGlTdWxPo2y96fFuW41j59vh
|
||||
XY54kI5sBFibuvxLJOr9lXw8EuXJTNiyKuoEoXu2QKNHYSOZi1OPzrJRsKxEwNBh
|
||||
8TP1G99H/gdlYEI/CPYOGbhWMq1qZyukDHjQaOMdzRIRYawx4GbQE1HeGla5bFSy
|
||||
n0Gki5ApqQk8b6muUxDXBgPdQKFL6o7KYhAg+8JsGvnByh7qVZl2kmwxjx2bJIcj
|
||||
o7BBRSYLSWdW3cguXojtgoN2NcFZZON4IEDSBuu/1ESgi2a2W5T9NClK/3ZagPmJ
|
||||
hX2T2qTTkVjWQ+xM15SD46s4s+5nZX2kGE1DHwtYSKgdHYR9n81po7CuEqVP1n/G
|
||||
7NNrMLXj3PGrZ2vzKDGSAU1LzLOUrJ4m
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Spring SSL Bundler Demo Application</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Spring SSL Bundler Demo Application</h1>
|
||||
<p>
|
||||
This is a sample application that can be built as native executable.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,12 @@
|
|||
package com.baeldung.springbootsslbundles;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SSLBundleApplicationTests {
|
||||
@Test
|
||||
void contextLoads() {
|
||||
|
||||
}
|
||||
}
|
|
@ -19,8 +19,4 @@ spring:
|
|||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5Dialect
|
||||
batch:
|
||||
initialize-schema: always
|
||||
maven:
|
||||
remoteRepositories:
|
||||
springRepo:
|
||||
url: https://repo.spring.io/libs-snapshot
|
||||
initialize-schema: always
|
|
@ -1 +0,0 @@
|
|||
maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot
|
|
@ -27,6 +27,7 @@
|
|||
<module>spring-5-reactive-filters</module>
|
||||
<module>spring-5-reactive-oauth</module>
|
||||
<module>spring-5-reactive-security</module>
|
||||
<module>spring-data-couchbase</module>
|
||||
<module>spring-reactive</module>
|
||||
<module>spring-reactive-exceptions</module>
|
||||
<module>spring-reactor</module>
|
||||
|
|
|
@ -6,5 +6,4 @@ This module contains articles about reactive Spring 5 Data
|
|||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles
|
||||
- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc)
|
||||
- [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase)
|
||||
- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc)
|
|
@ -26,15 +26,6 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<version>${reactor-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-couchbase-reactive</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
@ -42,21 +33,12 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -66,101 +48,27 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${spring-tx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-r2dbc</artifactId>
|
||||
<version>${spring-data-r2dbc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-h2</artifactId>
|
||||
<version>${r2dbc-h2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couchbase.mock</groupId>
|
||||
<artifactId>CouchbaseMock</artifactId>
|
||||
<version>${couchbaseMock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--add-opens java.base/java.util=ALL-UNNAMED
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
<executions>
|
||||
<!-- Replacing default-compile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<!-- Replacing default-testCompile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-tx.version>5.2.2.RELEASE</spring-tx.version>
|
||||
<spring-data-r2dbc.version>1.0.0.RELEASE</spring-data-r2dbc.version>
|
||||
<r2dbc-h2.version>0.8.1.RELEASE</r2dbc-h2.version>
|
||||
<httpclient.version>4.5.2</httpclient.version>
|
||||
<couchbaseMock.version>1.5.23</couchbaseMock.version>
|
||||
<reactor-core.version>3.3.1.RELEASE</reactor-core.version>
|
||||
<!-- This spring-boot.version is set manually, For upgrading this please refer http://team.baeldung.com/browse/JAVA-2802 -->
|
||||
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
|
||||
<log4j2.version>2.17.1</log4j2.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,6 +1,7 @@
|
|||
package com.baeldung.r2dbc;
|
||||
|
||||
|
||||
import com.baeldung.r2dbc.configuration.R2DBCConfiguration;
|
||||
import com.baeldung.r2dbc.model.Player;
|
||||
import com.baeldung.r2dbc.repository.PlayerRepository;
|
||||
import io.r2dbc.h2.H2ConnectionFactory;
|
||||
|
@ -9,7 +10,7 @@ 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.data.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Hooks;
|
||||
|
@ -20,7 +21,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(classes = R2DBCConfiguration.class)
|
||||
public class R2dbcApplicationIntegrationTest {
|
||||
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class R2dbcApplicationIntegrationTest {
|
|||
"DROP TABLE IF EXISTS player;",
|
||||
"CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);");
|
||||
|
||||
statements.forEach(it -> client.execute(it) //
|
||||
statements.forEach(it -> client.sql(it) //
|
||||
.fetch() //
|
||||
.rowsUpdated() //
|
||||
.as(StepVerifier::create) //
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
## Spring Data Reactive Project
|
||||
|
||||
This module contains articles about reactive Spring Data Couchbase
|
||||
|
||||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles
|
||||
- [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase)
|
|
@ -0,0 +1,146 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>spring-data-couchbase</artifactId>
|
||||
<name>spring-data-couchbase</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.reactive</groupId>
|
||||
<artifactId>spring-reactive-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-bom</artifactId>
|
||||
<version>${log4j2.version}</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<version>${reactor-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-couchbase-reactive</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${spring-tx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couchbase.mock</groupId>
|
||||
<artifactId>CouchbaseMock</artifactId>
|
||||
<version>${couchbaseMock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>
|
||||
--add-opens java.base/java.util=ALL-UNNAMED
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
<executions>
|
||||
<!-- Replacing default-compile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<!-- Replacing default-testCompile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-tx.version>5.2.2.RELEASE</spring-tx.version>
|
||||
<httpclient.version>4.5.2</httpclient.version>
|
||||
<couchbaseMock.version>1.5.23</couchbaseMock.version>
|
||||
<reactor-core.version>3.3.1.RELEASE</reactor-core.version>
|
||||
<!-- This spring-boot.version is set manually, For upgrading this please refer http://team.baeldung.com/browse/JAVA-2802 -->
|
||||
<spring-boot.version>2.2.6.RELEASE</spring-boot.version>
|
||||
<log4j2.version>2.17.1</log4j2.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -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>
|
Loading…
Reference in New Issue