Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
ce5d2c38a1
|
@ -83,4 +83,4 @@
|
||||||
<olingo.version>2.0.11</olingo.version>
|
<olingo.version>2.0.11</olingo.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -34,6 +34,28 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>core-java-9-new-features</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${maven.compiler.source}</source>
|
||||||
|
<target>${maven.compiler.target}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>apache.snapshots</id>
|
||||||
|
<url>https://repository.apache.org/snapshots/</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>incubator-features</id>
|
<id>incubator-features</id>
|
||||||
|
@ -126,28 +148,6 @@
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>core-java-9-new-features</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${maven.compiler.source}</source>
|
|
||||||
<target>${maven.compiler.target}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>apache.snapshots</id>
|
|
||||||
<url>https://repository.apache.org/snapshots/</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<rxjava.version>3.0.0</rxjava.version>
|
<rxjava.version>3.0.0</rxjava.version>
|
||||||
<awaitility.version>4.0.2</awaitility.version>
|
<awaitility.version>4.0.2</awaitility.version>
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
- [Start Two Threads at the Exact Same Time in Java](https://www.baeldung.com/java-start-two-threads-at-same-time)
|
- [Start Two Threads at the Exact Same Time in Java](https://www.baeldung.com/java-start-two-threads-at-same-time)
|
||||||
- [Volatile Variables and Thread Safety](https://www.baeldung.com/java-volatile-variables-thread-safety)
|
- [Volatile Variables and Thread Safety](https://www.baeldung.com/java-volatile-variables-thread-safety)
|
||||||
- [Producer-Consumer Problem With Example in Java](https://www.baeldung.com/java-producer-consumer-problem)
|
- [Producer-Consumer Problem With Example in Java](https://www.baeldung.com/java-producer-consumer-problem)
|
||||||
|
- [Acquire a Lock by a Key in Java](https://www.baeldung.com/java-acquire-lock-by-key)
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
public class Consumer implements Runnable {
|
||||||
|
private final DataQueue dataQueue;
|
||||||
|
private volatile boolean runFlag;
|
||||||
|
|
||||||
|
public Consumer(DataQueue dataQueue) {
|
||||||
|
this.dataQueue = dataQueue;
|
||||||
|
runFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void consume() {
|
||||||
|
while (runFlag) {
|
||||||
|
Message message;
|
||||||
|
if (dataQueue.isEmpty()) {
|
||||||
|
try {
|
||||||
|
dataQueue.waitOnEmpty();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!runFlag) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
message = dataQueue.remove();
|
||||||
|
dataQueue.notifyAllForFull();
|
||||||
|
useMessage(message);
|
||||||
|
}
|
||||||
|
System.out.println("Consumer Stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void useMessage(Message message) {
|
||||||
|
if (message != null) {
|
||||||
|
System.out.printf("[%s] Consuming Message. Id: %d, Data: %f\n", Thread.currentThread().getName(), message.getId(), message.getData());
|
||||||
|
|
||||||
|
//Sleeping on random time to make it realistic
|
||||||
|
ThreadUtil.sleep((long) (message.getData() * 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
runFlag = false;
|
||||||
|
dataQueue.notifyAllForEmpty();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
public class DataQueue {
|
||||||
|
private final Queue<Message> queue = new LinkedList<>();
|
||||||
|
private final int maxSize;
|
||||||
|
private final Object FULL_QUEUE = new Object();
|
||||||
|
private final Object EMPTY_QUEUE = new Object();
|
||||||
|
|
||||||
|
DataQueue(int maxSize) {
|
||||||
|
this.maxSize = maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFull() {
|
||||||
|
return queue.size() == maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return queue.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitOnFull() throws InterruptedException {
|
||||||
|
synchronized (FULL_QUEUE) {
|
||||||
|
FULL_QUEUE.wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitOnEmpty() throws InterruptedException {
|
||||||
|
synchronized (EMPTY_QUEUE) {
|
||||||
|
EMPTY_QUEUE.wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyAllForFull() {
|
||||||
|
synchronized (FULL_QUEUE) {
|
||||||
|
FULL_QUEUE.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyAllForEmpty() {
|
||||||
|
synchronized (EMPTY_QUEUE) {
|
||||||
|
EMPTY_QUEUE.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Message message) {
|
||||||
|
synchronized (queue) {
|
||||||
|
queue.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Message remove() {
|
||||||
|
synchronized (queue) {
|
||||||
|
return queue.poll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
public class Message {
|
||||||
|
private int id;
|
||||||
|
private double data;
|
||||||
|
|
||||||
|
public Message(int id, double data) {
|
||||||
|
this.id = id;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(double data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
public class Producer implements Runnable {
|
||||||
|
private final DataQueue dataQueue;
|
||||||
|
private volatile boolean runFlag;
|
||||||
|
|
||||||
|
private static int idSequence = 0;
|
||||||
|
|
||||||
|
public Producer(DataQueue dataQueue) {
|
||||||
|
this.dataQueue = dataQueue;
|
||||||
|
runFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
produce();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void produce() {
|
||||||
|
while (runFlag) {
|
||||||
|
Message message = generateMessage();
|
||||||
|
while (dataQueue.isFull()) {
|
||||||
|
try {
|
||||||
|
dataQueue.waitOnFull();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!runFlag) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dataQueue.add(message);
|
||||||
|
dataQueue.notifyAllForEmpty();
|
||||||
|
}
|
||||||
|
System.out.println("Producer Stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Message generateMessage() {
|
||||||
|
Message message = new Message(++idSequence, Math.random());
|
||||||
|
System.out.printf("[%s] Generated Message. Id: %d, Data: %f\n", Thread.currentThread().getName(), message.getId(), message.getData());
|
||||||
|
|
||||||
|
//Sleeping on random time to make it realistic
|
||||||
|
ThreadUtil.sleep((long) (message.getData() * 100));
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
runFlag = false;
|
||||||
|
dataQueue.notifyAllForFull();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.baeldung.producerconsumer.ThreadUtil.*;
|
||||||
|
|
||||||
|
public class ProducerConsumerDemonstrator {
|
||||||
|
private static final int MAX_QUEUE_CAPACITY = 5;
|
||||||
|
|
||||||
|
public static void demoSingleProducerAndSingleConsumer() {
|
||||||
|
DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY);
|
||||||
|
|
||||||
|
Producer producer = new Producer(dataQueue);
|
||||||
|
Thread producerThread = new Thread(producer);
|
||||||
|
|
||||||
|
Consumer consumer = new Consumer(dataQueue);
|
||||||
|
Thread consumerThread = new Thread(consumer);
|
||||||
|
|
||||||
|
producerThread.start();
|
||||||
|
consumerThread.start();
|
||||||
|
|
||||||
|
List<Thread> threads = new ArrayList<>();
|
||||||
|
threads.add(producerThread);
|
||||||
|
threads.add(consumerThread);
|
||||||
|
|
||||||
|
// let threads run for two seconds
|
||||||
|
sleep(2000);
|
||||||
|
|
||||||
|
// Stop threads
|
||||||
|
producer.stop();
|
||||||
|
consumer.stop();
|
||||||
|
|
||||||
|
waitForAllThreadsToComplete(threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void demoMultipleProducersAndMultipleConsumers() {
|
||||||
|
DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY);
|
||||||
|
int producerCount = 3;
|
||||||
|
int consumerCount = 3;
|
||||||
|
List<Thread> threads = new ArrayList<>();
|
||||||
|
Producer producer = new Producer(dataQueue);
|
||||||
|
for(int i = 0; i < producerCount; i++) {
|
||||||
|
Thread producerThread = new Thread(producer);
|
||||||
|
producerThread.start();
|
||||||
|
threads.add(producerThread);
|
||||||
|
}
|
||||||
|
Consumer consumer = new Consumer(dataQueue);
|
||||||
|
for(int i = 0; i < consumerCount; i++) {
|
||||||
|
Thread consumerThread = new Thread(consumer);
|
||||||
|
consumerThread.start();
|
||||||
|
threads.add(consumerThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
// let threads run for two seconds
|
||||||
|
sleep(2000);
|
||||||
|
|
||||||
|
// Stop threads
|
||||||
|
producer.stop();
|
||||||
|
consumer.stop();
|
||||||
|
|
||||||
|
waitForAllThreadsToComplete(threads);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
demoSingleProducerAndSingleConsumer();
|
||||||
|
demoMultipleProducersAndMultipleConsumers();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
|
||||||
|
import static com.baeldung.producerconsumer.ThreadUtil.sleep;
|
||||||
|
|
||||||
|
public class SimpleProducerConsumerDemonstrator {
|
||||||
|
BlockingQueue<Double> blockingQueue = new LinkedBlockingDeque<>(5);
|
||||||
|
|
||||||
|
private void produce() {
|
||||||
|
while (true) {
|
||||||
|
double value = generateValue();
|
||||||
|
try {
|
||||||
|
blockingQueue.put(value);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
System.out.printf("[%s] Value produced: %f\n", Thread.currentThread().getName(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void consume() {
|
||||||
|
while (true) {
|
||||||
|
Double value;
|
||||||
|
try {
|
||||||
|
value = blockingQueue.take();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Consume value
|
||||||
|
System.out.printf("[%s] Value consumed: %f\n", Thread.currentThread().getName(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double generateValue() {
|
||||||
|
return Math.random();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runProducerConsumer() {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
Thread producerThread = new Thread(this::produce);
|
||||||
|
producerThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
Thread consumerThread = new Thread(this::consume);
|
||||||
|
consumerThread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SimpleProducerConsumerDemonstrator simpleProducerConsumerDemonstrator = new SimpleProducerConsumerDemonstrator();
|
||||||
|
simpleProducerConsumerDemonstrator.runProducerConsumer();
|
||||||
|
sleep(2000);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.baeldung.producerconsumer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ThreadUtil {
|
||||||
|
public static void waitForAllThreadsToComplete(List<Thread> threads) {
|
||||||
|
for(Thread thread: threads) {
|
||||||
|
try {
|
||||||
|
thread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sleep(long interval) {
|
||||||
|
try {
|
||||||
|
// Wait for some time to demonstrate threads
|
||||||
|
Thread.sleep(interval);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,4 +24,4 @@
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -25,7 +25,6 @@
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>${commons-lang3.version}</version>
|
<version>${commons-lang3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.darwinsys</groupId>
|
<groupId>com.darwinsys</groupId>
|
||||||
<artifactId>hirondelle-date4j</artifactId>
|
<artifactId>hirondelle-date4j</artifactId>
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
- [Java ArrayIndexOutOfBoundsException](https://www.baeldung.com/java-arrayindexoutofboundsexception)
|
- [Java ArrayIndexOutOfBoundsException](https://www.baeldung.com/java-arrayindexoutofboundsexception)
|
||||||
- [Java Missing Return Statement](https://www.baeldung.com/java-missing-return-statement)
|
- [Java Missing Return Statement](https://www.baeldung.com/java-missing-return-statement)
|
||||||
|
- [Convert long to int Type in Java](https://www.baeldung.com/java-convert-long-to-int)
|
||||||
|
|
|
@ -259,7 +259,7 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -64,13 +64,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<javaassist.version>3.27.0-GA</javaassist.version>
|
|
||||||
<sun.tools.version>1.8.0</sun.tools.version>
|
|
||||||
<jol-core.version>0.10</jol-core.version>
|
|
||||||
<asm.version>8.0.1</asm.version>
|
|
||||||
<bcel.version>6.5.0</bcel.version>
|
|
||||||
</properties>
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<!-- java instrumentation profiles to build jars -->
|
<!-- java instrumentation profiles to build jars -->
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -181,4 +174,12 @@
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<javaassist.version>3.27.0-GA</javaassist.version>
|
||||||
|
<sun.tools.version>1.8.0</sun.tools.version>
|
||||||
|
<jol-core.version>0.10</jol-core.version>
|
||||||
|
<asm.version>8.0.1</asm.version>
|
||||||
|
<bcel.version>6.5.0</bcel.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -10,3 +10,4 @@ This module contains articles about core features in the Java language
|
||||||
- [Tiered Compilation in JVM](https://www.baeldung.com/jvm-tiered-compilation)
|
- [Tiered Compilation in JVM](https://www.baeldung.com/jvm-tiered-compilation)
|
||||||
- [Fixing the “Declared package does not match the expected package” Error](https://www.baeldung.com/java-declared-expected-package-error)
|
- [Fixing the “Declared package does not match the expected package” Error](https://www.baeldung.com/java-declared-expected-package-error)
|
||||||
- [Chaining Constructors in Java](https://www.baeldung.com/java-chain-constructors)
|
- [Chaining Constructors in Java](https://www.baeldung.com/java-chain-constructors)
|
||||||
|
- [Difference Between POJO, JavaBeans, DTO and VO](https://www.baeldung.com/java-pojo-javabeans-dto-vo)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.baeldung.employee;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public class EmployeeBean implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3760445487636086034L;
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private LocalDate startDate;
|
||||||
|
|
||||||
|
public EmployeeBean() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeBean(String firstName, String lastName, LocalDate startDate) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(LocalDate startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.baeldung.employee;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public class EmployeeDTO {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private LocalDate startDate;
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(LocalDate startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.baeldung.employee;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EmployeePOJO {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private LocalDate startDate;
|
||||||
|
|
||||||
|
public EmployeePOJO(String firstName, String lastName, LocalDate startDate) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return this.firstName + " " + this.lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStart() {
|
||||||
|
return this.startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(LocalDate startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.baeldung.employee;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EmployeeVO {
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private LocalDate startDate;
|
||||||
|
|
||||||
|
public EmployeeVO(String firstName, String lastName, LocalDate startDate) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return Objects.equals(firstName, this.firstName)
|
||||||
|
&& Objects.equals(lastName, this.lastName)
|
||||||
|
&& Objects.equals(startDate, this.startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(firstName, lastName, startDate);
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,7 +64,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -54,4 +54,5 @@
|
||||||
<validator.version>1.7</validator.version>
|
<validator.version>1.7</validator.version>
|
||||||
<apache-commons-lang3.version>3.12.0</apache-commons-lang3.version>
|
<apache-commons-lang3.version>3.12.0</apache-commons-lang3.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -69,7 +69,6 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -137,4 +137,4 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,13 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.dddmodules.infrastructure</groupId>
|
<groupId>com.baeldung.dddmodules.infrastructure</groupId>
|
||||||
<artifactId>infrastructure</artifactId>
|
<artifactId>infrastructure</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
<groupId>com.baeldung.dddmodules</groupId>
|
<groupId>com.baeldung.dddmodules</groupId>
|
||||||
<artifactId>ddd-modules</artifactId>
|
<artifactId>ddd-modules</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<relativePath>../</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -14,7 +13,6 @@
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@ -70,10 +68,8 @@
|
||||||
<properties>
|
<properties>
|
||||||
<source.version>9</source.version>
|
<source.version>9</source.version>
|
||||||
<target.version>9</target.version>
|
<target.version>9</target.version>
|
||||||
|
|
||||||
<compiler.plugin.version>3.8.1</compiler.plugin.version>
|
<compiler.plugin.version>3.8.1</compiler.plugin.version>
|
||||||
|
|
||||||
<appmodules.version>1.0</appmodules.version>
|
<appmodules.version>1.0</appmodules.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
<groupId>com.baeldung.dddmodules</groupId>
|
<groupId>com.baeldung.dddmodules</groupId>
|
||||||
<artifactId>ddd-modules</artifactId>
|
<artifactId>ddd-modules</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<relativePath>../</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
<groupId>com.baeldung.dddmodules</groupId>
|
<groupId>com.baeldung.dddmodules</groupId>
|
||||||
<artifactId>ddd-modules</artifactId>
|
<artifactId>ddd-modules</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<relativePath>../</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>osgeo-release</id>
|
||||||
|
<name>OSGeo Repository</name>
|
||||||
|
<url>https://repo.osgeo.org/repository/release/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geotools</groupId>
|
<groupId>org.geotools</groupId>
|
||||||
|
@ -33,14 +41,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>osgeo-release</id>
|
|
||||||
<name>OSGeo Repository</name>
|
|
||||||
<url>https://repo.osgeo.org/repository/release/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<geotools.version>15.2</geotools.version>
|
<geotools.version>15.2</geotools.version>
|
||||||
<geotools-swing.version>15.2</geotools-swing.version>
|
<geotools-swing.version>15.2</geotools-swing.version>
|
||||||
|
|
|
@ -33,26 +33,22 @@
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<version>2.6.2</version>
|
<version>2.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>2.6.2</version>
|
<version>2.6.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.netflix.graphql.dgs.codegen</groupId>
|
<groupId>com.netflix.graphql.dgs.codegen</groupId>
|
||||||
<artifactId>graphql-dgs-codegen-client-core</artifactId>
|
<artifactId>graphql-dgs-codegen-client-core</artifactId>
|
||||||
<version>5.1.14</version>
|
<version>5.1.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>2.6.2</version>
|
<version>2.6.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.netflix.graphql.dgs</groupId>
|
<groupId>com.netflix.graphql.dgs</groupId>
|
||||||
<artifactId>graphql-dgs-spring-boot-starter</artifactId>
|
<artifactId>graphql-dgs-spring-boot-starter</artifactId>
|
||||||
|
@ -88,4 +84,4 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<project 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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>httpclient-2</artifactId>
|
<artifactId>httpclient-2</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Introduction to Jakarta EE MVC / Eclipse Krazo](https://www.baeldung.com/java-ee-mvc-eclipse-krazo)
|
|
@ -22,7 +22,6 @@
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.8.1</version>
|
<version>5.8.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
- [Understanding the & 0xff Value in Java](https://www.baeldung.com/java-and-0xff)
|
- [Understanding the & 0xff Value in Java](https://www.baeldung.com/java-and-0xff)
|
||||||
- [Determine if an Integer’s Square Root Is an Integer in Java](https://www.baeldung.com/java-find-if-square-root-is-integer)
|
- [Determine if an Integer’s Square Root Is an Integer in Java](https://www.baeldung.com/java-find-if-square-root-is-integer)
|
||||||
- [Guide to Java BigInteger](https://www.baeldung.com/java-biginteger)
|
- [Guide to Java BigInteger](https://www.baeldung.com/java-biginteger)
|
||||||
|
- [Automorphic Numbers in Java](https://www.baeldung.com/java-automorphic-numbers)
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.baeldung.automorphicnumber;
|
||||||
|
|
||||||
|
public class AutomorphicNumber {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(isAutomorphicUsingLoop(76));
|
||||||
|
System.out.println(isAutomorphicUsingMath(76));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAutomorphicUsingMath(int number) {
|
||||||
|
int square = number * number;
|
||||||
|
|
||||||
|
int numberOfDigits = (int) Math.floor(Math.log10(number) + 1);
|
||||||
|
int lastDigits = (int) (square % (Math.pow(10, numberOfDigits)));
|
||||||
|
|
||||||
|
return number == lastDigits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAutomorphicUsingLoop(int number) {
|
||||||
|
int square = number * number;
|
||||||
|
|
||||||
|
while (number > 0) {
|
||||||
|
if (number % 10 != square % 10) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
number /= 10;
|
||||||
|
square /= 10;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.automorphicnumber;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class AutomorphicNumberUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenANumber_whenPassed_thenShouldDetermineAutomorphicOrNot() {
|
||||||
|
int number1 = 76; // automorphic
|
||||||
|
int number2 = 16; // not automorphic
|
||||||
|
assertTrue(AutomorphicNumber.isAutomorphicUsingLoop(number1));
|
||||||
|
assertFalse(AutomorphicNumber.isAutomorphicUsingLoop(number2));
|
||||||
|
assertTrue(AutomorphicNumber.isAutomorphicUsingMath(number1));
|
||||||
|
assertFalse(AutomorphicNumber.isAutomorphicUsingMath(number2));
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,4 +57,5 @@
|
||||||
<org.apache.httpcomponents.version>4.5.13</org.apache.httpcomponents.version>
|
<org.apache.httpcomponents.version>4.5.13</org.apache.httpcomponents.version>
|
||||||
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
|
||||||
|
</project>
|
|
@ -37,35 +37,13 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- uncomment in order to enable Hibernate Validator Anotation Processor -->
|
<!-- uncomment in order to enable Hibernate Validator Anotation Processor -->
|
||||||
<!--
|
<!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
|
||||||
<build>
|
<version>${maven.compiler.version}</version> <configuration> <source>${maven.compiler.source}</source>
|
||||||
<plugins>
|
<target>${maven.compiler.target}</target> <fork>true</fork> <compilerArgs> <arg>-Averbose=true</arg>
|
||||||
<plugin>
|
<arg>-AmethodConstraintsSupported=true</arg> <arg>-AdiagnosticKind=ERROR</arg> </compilerArgs> <annotationProcessorPaths>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<path> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator-annotation-processor</artifactId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<version>${hibernate-validator.ap.version}</version> </path> </annotationProcessorPaths> </configuration>
|
||||||
<version>${maven.compiler.version}</version>
|
</plugin> </plugins> </build> -->
|
||||||
<configuration>
|
|
||||||
<source>${maven.compiler.source}</source>
|
|
||||||
<target>${maven.compiler.target}</target>
|
|
||||||
<fork>true</fork>
|
|
||||||
<compilerArgs>
|
|
||||||
<arg>-Averbose=true</arg>
|
|
||||||
<arg>-AmethodConstraintsSupported=true</arg>
|
|
||||||
<arg>-AdiagnosticKind=ERROR</arg>
|
|
||||||
</compilerArgs>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.hibernate.validator</groupId>
|
|
||||||
<artifactId>hibernate-validator-annotation-processor</artifactId>
|
|
||||||
<version>${hibernate-validator.ap.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
||||||
|
@ -77,4 +55,4 @@
|
||||||
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
<org.springframework.version>5.0.2.RELEASE</org.springframework.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -15,7 +15,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-2</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>libraries-concurrency</artifactId>
|
<artifactId>libraries-concurrency</artifactId>
|
||||||
<name>libraries-concurrency</name>
|
<name>libraries-concurrency</name>
|
||||||
|
@ -78,5 +78,5 @@
|
||||||
<properties>
|
<properties>
|
||||||
<quasar.version>0.8.0</quasar.version>
|
<quasar.version>0.8.0</quasar.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -22,4 +22,4 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -62,18 +62,9 @@
|
||||||
<verbose>false</verbose>
|
<verbose>false</verbose>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- This is for delomboking also your tests sources.
|
<!-- This is for delomboking also your tests sources. <execution> <id>test-delombok</id>
|
||||||
<execution>
|
<phase>generate-test-sources</phase> <goals> <goal>testDelombok</goal> </goals> <configuration> <verbose>false</verbose>
|
||||||
<id>test-delombok</id>
|
</configuration> </execution> -->
|
||||||
<phase>generate-test-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>testDelombok</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<verbose>false</verbose>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
-->
|
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>maven-classifier-example-consumer</artifactId>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>maven-classifier</artifactId>
|
<artifactId>maven-classifier</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>maven-classifier-example-consumer</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
|
@ -29,13 +23,14 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<classifier>arbitrary</classifier>
|
<classifier>arbitrary</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- For example purpose not building as it requires both JDK 8 and 11 executables on the build machine -->
|
<!-- For example purpose not building as it requires both JDK 8 and 11 executables on the build
|
||||||
<!-- <dependency>-->
|
machine -->
|
||||||
<!-- <groupId>com.baeldung</groupId>-->
|
<!-- <dependency> -->
|
||||||
<!-- <artifactId>maven-classifier-example-provider</artifactId>-->
|
<!-- <groupId>com.baeldung</groupId> -->
|
||||||
<!-- <version>0.0.1-SNAPSHOT</version>-->
|
<!-- <artifactId>maven-classifier-example-provider</artifactId> -->
|
||||||
<!-- <classifier>jdk11</classifier>-->
|
<!-- <version>0.0.1-SNAPSHOT</version> -->
|
||||||
<!-- </dependency>-->
|
<!-- <classifier>jdk11</classifier> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>maven-classifier-example-provider</artifactId>
|
<artifactId>maven-classifier-example-provider</artifactId>
|
||||||
|
@ -50,4 +45,9 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>maven-classifier-example-provider</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>maven-classifier</artifactId>
|
<artifactId>maven-classifier</artifactId>
|
||||||
|
@ -11,15 +12,6 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>maven-classifier-example-provider</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<!-- <jdk.11.executable.path></jdk.11.executable.path>-->
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -39,21 +31,22 @@
|
||||||
<fork>true</fork>
|
<fork>true</fork>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- For example purpose not building as it requires both JDK 8 and 11 executables on the build machine -->
|
<!-- For example purpose not building as it requires both JDK 8 and 11 executables
|
||||||
<!-- <execution>-->
|
on the build machine -->
|
||||||
<!-- <id>JDK 11</id>-->
|
<!-- <execution> -->
|
||||||
<!-- <phase>compile</phase>-->
|
<!-- <id>JDK 11</id> -->
|
||||||
<!-- <goals>-->
|
<!-- <phase>compile</phase> -->
|
||||||
<!-- <goal>compile</goal>-->
|
<!-- <goals> -->
|
||||||
<!-- </goals>-->
|
<!-- <goal>compile</goal> -->
|
||||||
<!-- <configuration>-->
|
<!-- </goals> -->
|
||||||
<!-- <fork>true</fork>-->
|
<!-- <configuration> -->
|
||||||
<!-- <outputDirectory>${project.build.outputDirectory}_jdk11</outputDirectory>-->
|
<!-- <fork>true</fork> -->
|
||||||
<!-- <executable>${jdk.11.executable.path}</executable>-->
|
<!-- <outputDirectory>${project.build.outputDirectory}_jdk11</outputDirectory> -->
|
||||||
<!-- <source>8</source>-->
|
<!-- <executable>${jdk.11.executable.path}</executable> -->
|
||||||
<!-- <target>11</target>-->
|
<!-- <source>8</source> -->
|
||||||
<!-- </configuration>-->
|
<!-- <target>11</target> -->
|
||||||
<!-- </execution>-->
|
<!-- </configuration> -->
|
||||||
|
<!-- </execution> -->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -76,18 +69,19 @@
|
||||||
<goal>test-jar</goal>
|
<goal>test-jar</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- For example purpose not building as it requires both JDK 8 and 11 executables on the build machine -->
|
<!-- For example purpose not building as it requires both JDK 8 and 11 executables
|
||||||
<!-- <execution>-->
|
on the build machine -->
|
||||||
<!-- <id>default-package-jdk11</id>-->
|
<!-- <execution> -->
|
||||||
<!-- <phase>package</phase>-->
|
<!-- <id>default-package-jdk11</id> -->
|
||||||
<!-- <goals>-->
|
<!-- <phase>package</phase> -->
|
||||||
<!-- <goal>jar</goal>-->
|
<!-- <goals> -->
|
||||||
<!-- </goals>-->
|
<!-- <goal>jar</goal> -->
|
||||||
<!-- <configuration>-->
|
<!-- </goals> -->
|
||||||
<!-- <classesDirectory>${project.build.outputDirectory}_jdk11</classesDirectory>-->
|
<!-- <configuration> -->
|
||||||
<!-- <classifier>jdk11</classifier>-->
|
<!-- <classesDirectory>${project.build.outputDirectory}_jdk11</classesDirectory> -->
|
||||||
<!-- </configuration>-->
|
<!-- <classifier>jdk11</classifier> -->
|
||||||
<!-- </execution>-->
|
<!-- </configuration> -->
|
||||||
|
<!-- </execution> -->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -119,4 +113,11 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<!-- <jdk.11.executable.path></jdk.11.executable.path> -->
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>maven-classifier</artifactId>
|
<artifactId>maven-classifier</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
@ -24,4 +23,4 @@
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -3,9 +3,7 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>copy-rename-maven-plugin</name>
|
<name>copy-rename-maven-plugin</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>maven-antrun-plugin</name>
|
<name>maven-antrun-plugin</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>maven-resources-plugin</name>
|
<name>maven-resources-plugin</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>maven-generate-war</artifactId>
|
<artifactId>maven-generate-war</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
|
||||||
<name>maven-generate-war</name>
|
<name>maven-generate-war</name>
|
||||||
|
<packaging>war</packaging>
|
||||||
<description>Spring boot project to demonstrate war file generation</description>
|
<description>Spring boot project to demonstrate war file generation</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
|
@ -4,13 +4,12 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>maven-dependency</artifactId>
|
<artifactId>maven-dependency</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>maven-simple</artifactId>
|
<artifactId>maven-simple</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -3,14 +3,24 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<name>core</name>
|
<name>core</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-project</artifactId>
|
<artifactId>parent-project</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
</project>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-core</artifactId>
|
||||||
|
<version>${spring-core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<spring-core.version>4.3.30.RELEASE</spring-core.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -4,6 +4,7 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>parent-project</artifactId>
|
<artifactId>parent-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>parent-project</name>
|
<name>parent-project</name>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@ -18,4 +19,18 @@
|
||||||
<module>service</module>
|
<module>service</module>
|
||||||
<module>webapp</module>
|
<module>webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-core</artifactId>
|
||||||
|
<version>${spring-core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<spring-core.version>5.3.16</spring-core.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -3,14 +3,13 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>service</artifactId>
|
<artifactId>service</artifactId>
|
||||||
<name>service</name>
|
<name>service</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-project</artifactId>
|
<artifactId>parent-project</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -3,14 +3,31 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
|
||||||
<artifactId>webapp</artifactId>
|
<artifactId>webapp</artifactId>
|
||||||
<name>webapp</name>
|
<name>webapp</name>
|
||||||
|
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-project</artifactId>
|
<artifactId>parent-project</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
</project>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>${maven-war-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -92,4 +92,4 @@
|
||||||
<metrics-aspectj.version>1.1.0</metrics-aspectj.version>
|
<metrics-aspectj.version>1.1.0</metrics-aspectj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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"
|
<project 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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>netty</artifactId>
|
<artifactId>netty</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
@ -11,20 +12,18 @@
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>${netty.version}</version>
|
<version>${netty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.conscrypt</groupId>
|
<groupId>org.conscrypt</groupId>
|
||||||
<artifactId>conscrypt-openjdk-uber</artifactId>
|
<artifactId>conscrypt-openjdk-uber</artifactId>
|
||||||
<version>${conscrypt-openjdk-uber.version}</version>
|
<version>${conscrypt-openjdk-uber.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Using Nginx as a Forward Proxy](https://www.baeldung.com/nginx-forward-proxy)
|
|
@ -16,6 +16,25 @@
|
||||||
<module>wire-tap</module>
|
<module>wire-tap</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.camel.springboot</groupId>
|
||||||
|
<artifactId>camel-spring-boot-dependencies</artifactId>
|
||||||
|
<version>${camel.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.camel.springboot</groupId>
|
<groupId>org.apache.camel.springboot</groupId>
|
||||||
|
@ -39,25 +58,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.camel.springboot</groupId>
|
|
||||||
<artifactId>camel-spring-boot-dependencies</artifactId>
|
|
||||||
<version>${camel.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-bom</artifactId>
|
|
||||||
<version>${log4j2.version}</version>
|
|
||||||
<scope>import</scope>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<camel.version>3.7.4</camel.version>
|
<camel.version>3.7.4</camel.version>
|
||||||
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
|
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
|
||||||
<log4j2.version>2.17.1</log4j2.version>
|
<log4j2.version>2.17.1</log4j2.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,3 @@
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Building a web app Using Fauna and Spring for Your First web Agency Client](https://www.baeldung.com/faunadb-spring-web-app)
|
|
@ -54,22 +54,22 @@
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>${h2.version}</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>${com.sun.xml.version}</version>
|
<version>${com.sun.xml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
<version>${javax.xml.bind.version}</version>
|
<version>${javax.xml.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>${com.sun.xml.version}</version>
|
<version>${com.sun.xml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -77,4 +77,4 @@
|
||||||
<netty-transport-version>4.1.71.Final</netty-transport-version>
|
<netty-transport-version>4.1.71.Final</netty-transport-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,5 @@
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
target
|
||||||
|
build
|
|
@ -0,0 +1,5 @@
|
||||||
|
## MongoDB
|
||||||
|
|
||||||
|
This module contains articles about MongoDB in Java.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?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>java-mongodb-2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>java-mongodb-2</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>persistence-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.flapdoodle.embedmongo</groupId>
|
||||||
|
<artifactId>de.flapdoodle.embedmongo</artifactId>
|
||||||
|
<version>${flapdoodle.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
|
<version>${mongo.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.morphia.morphia</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>${morphia.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>mongodb</artifactId>
|
||||||
|
<version>1.16.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>1.16.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<mongo.version>3.12.1</mongo.version>
|
||||||
|
<flapdoodle.version>1.11</flapdoodle.version>
|
||||||
|
<morphia.version>1.5.3</morphia.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.baeldung.mongo.update;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
import com.mongodb.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import com.mongodb.client.model.Filters;
|
||||||
|
import com.mongodb.client.model.Updates;
|
||||||
|
import com.mongodb.client.result.UpdateResult;
|
||||||
|
|
||||||
|
public class PustSetOperation {
|
||||||
|
|
||||||
|
private static MongoClient mongoClient;
|
||||||
|
|
||||||
|
private static String testCollectionName;
|
||||||
|
private static String databaseName;
|
||||||
|
|
||||||
|
public static void setUp() {
|
||||||
|
if (mongoClient == null) {
|
||||||
|
mongoClient = new MongoClient("localhost", 27017);
|
||||||
|
}
|
||||||
|
databaseName = "baeldung";
|
||||||
|
testCollectionName = "marks";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushSetSolution() {
|
||||||
|
|
||||||
|
MongoDatabase database = mongoClient.getDatabase(databaseName);
|
||||||
|
MongoCollection<Document> collection = database.getCollection(testCollectionName);
|
||||||
|
|
||||||
|
Document subjectData = new Document().append("subjectId", 126)
|
||||||
|
.append("subjectName", "Java Programming")
|
||||||
|
.append("marks", 70);
|
||||||
|
UpdateResult updateQueryResult = collection.updateOne(Filters.eq("studentId", 1023), Updates.combine(Updates.set("totalMarks", 170), Updates.push("subjectDetails", subjectData)));
|
||||||
|
System.out.println("updateQueryResult:- " + updateQueryResult);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Connect to cluster (default is localhost:27017)
|
||||||
|
//
|
||||||
|
setUp();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Push document into the array and set a field
|
||||||
|
//
|
||||||
|
pushSetSolution();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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>
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.baeldung.update;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.mongodb.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import com.mongodb.client.model.Filters;
|
||||||
|
import com.mongodb.client.model.Updates;
|
||||||
|
import com.mongodb.client.result.UpdateResult;
|
||||||
|
|
||||||
|
public class PustSetOperationLiveTest {
|
||||||
|
|
||||||
|
private static MongoClient mongoClient;
|
||||||
|
private static MongoDatabase db;
|
||||||
|
private static MongoCollection<Document> collection;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() {
|
||||||
|
if (mongoClient == null) {
|
||||||
|
mongoClient = new MongoClient("localhost", 27017);
|
||||||
|
db = mongoClient.getDatabase("baeldung");
|
||||||
|
collection = db.getCollection("marks");
|
||||||
|
|
||||||
|
collection.insertOne(Document.parse("{\n" + " \"studentId\": 1023,\n" + " \"studentName\":\"James Broad\",\n" + " \"joiningYear\":\"2018\",\n" + " \"totalMarks\":100,\n" + " \"subjectDetails\":[\n"
|
||||||
|
+ " {\n" + " \"subjectId\":123,\n" + " \"subjectName\":\"Operating Systems Concepts\",\n" + " \"marks\":4,\n" + " },\n" + " {\n"
|
||||||
|
+ " \"subjectId\":124,\n" + " \"subjectName\":\"Numerical Analysis\",\n" + " \"marks\":60\n" + " }\n" + " ]\n" + " }"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenMarksCollection_whenPushSetOperation_thenCheckingForDocument() {
|
||||||
|
|
||||||
|
Document subjectData = new Document().append("subjectId", 126)
|
||||||
|
.append("subjectName", "Java Programming")
|
||||||
|
.append("marks", 70);
|
||||||
|
UpdateResult updateQueryResult = collection.updateOne(Filters.eq("studentId", 1023), Updates.combine(Updates.set("totalMarks", 170), Updates.push("subjectDetails", subjectData)));
|
||||||
|
|
||||||
|
Document studentDetail = collection.find(Filters.eq("studentId", 1023))
|
||||||
|
.first();
|
||||||
|
assertNotNull(studentDetail);
|
||||||
|
assertFalse(studentDetail.isEmpty());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -14,3 +14,7 @@ This module contains articles about MongoDB in Java.
|
||||||
- [How to Check Field Existence in MongoDB?](https://www.baeldung.com/mongodb-check-field-exists)
|
- [How to Check Field Existence in MongoDB?](https://www.baeldung.com/mongodb-check-field-exists)
|
||||||
- [Get Last Inserted Document ID in MongoDB With Java Driver](https://www.baeldung.com/java-mongodb-last-inserted-id)
|
- [Get Last Inserted Document ID in MongoDB With Java Driver](https://www.baeldung.com/java-mongodb-last-inserted-id)
|
||||||
- [Update Multiple Fields in a MongoDB Document](https://www.baeldung.com/mongodb-update-multiple-fields)
|
- [Update Multiple Fields in a MongoDB Document](https://www.baeldung.com/mongodb-update-multiple-fields)
|
||||||
|
- [Update Documents in MongoDB](https://www.baeldung.com/mongodb-update-documents)
|
||||||
|
- [Check Collection Existence in MongoDB](https://www.baeldung.com/java-check-collection-existence-mongodb)
|
||||||
|
- [Case Insensitive Sorting in MongoDB](https://www.baeldung.com/java-mongodb-case-insensitive-sorting)
|
||||||
|
- [Push and Set Operations in Same MongoDB Update](https://www.baeldung.com/java-mongodb-push-set)
|
||||||
|
|
|
@ -30,6 +30,18 @@
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>${morphia.version}</version>
|
<version>${morphia.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>mongodb</artifactId>
|
||||||
|
<version>1.16.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>1.16.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.baeldung.ordering.caseinsensitive;
|
||||||
|
|
||||||
|
import com.mongodb.MongoClient;
|
||||||
|
import com.mongodb.client.*;
|
||||||
|
import com.mongodb.client.model.Collation;
|
||||||
|
import com.mongodb.client.model.Projections;
|
||||||
|
import com.mongodb.client.model.Sorts;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bson.conversions.Bson;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.testcontainers.containers.MongoDBContainer;
|
||||||
|
import org.testcontainers.junit.jupiter.Container;
|
||||||
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
import org.testcontainers.utility.DockerImageName;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.mongodb.client.model.Aggregates.project;
|
||||||
|
import static com.mongodb.client.model.Aggregates.sort;
|
||||||
|
import static com.mongodb.client.model.Sorts.ascending;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@Testcontainers
|
||||||
|
class CaseInsensitiveOrderingLiveTest {
|
||||||
|
|
||||||
|
private static MongoCollection<Document> userCollections;
|
||||||
|
|
||||||
|
@Container
|
||||||
|
private static final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"));
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
private static void setup() {
|
||||||
|
|
||||||
|
MongoClient mongoClient = new MongoClient(mongoDBContainer.getContainerIpAddress(), mongoDBContainer.getMappedPort(27017));
|
||||||
|
MongoDatabase database = mongoClient.getDatabase("test");
|
||||||
|
userCollections = database.getCollection("users");
|
||||||
|
|
||||||
|
List<Document> list = new ArrayList<>();
|
||||||
|
list.add(Document.parse("{'name': 'ben', surname: 'ThisField' }"));
|
||||||
|
list.add(Document.parse("{'name': 'aen', surname: 'Does' }"));
|
||||||
|
list.add(Document.parse("{'name': 'Ben', surname: 'Not' }"));
|
||||||
|
list.add(Document.parse("{'name': 'cen', surname: 'Matter' }"));
|
||||||
|
list.add(Document.parse("{'name': 'Aen', surname: 'Really' }"));
|
||||||
|
list.add(Document.parse("{'name': 'Cen', surname: 'TrustMe' }"));
|
||||||
|
|
||||||
|
userCollections.insertMany(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenMongoCollection_whenUsingFindWithSort_caseIsConsideredByDefault() {
|
||||||
|
FindIterable<Document> nameDoc = userCollections.find().sort(ascending("name"));
|
||||||
|
MongoCursor<Document> cursor = nameDoc.cursor();
|
||||||
|
|
||||||
|
List<String> expectedNamesOrdering = Arrays.asList("Aen", "Ben", "Cen", "aen", "ben", "cen");
|
||||||
|
List<String> actualNamesOrdering = new ArrayList<>();
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
Document document = cursor.next();
|
||||||
|
actualNamesOrdering.add(document.get("name").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(expectedNamesOrdering, actualNamesOrdering);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenMongoCollection_whenUsingFindWithSortAndCollation_caseIsNotConsidered() {
|
||||||
|
FindIterable<Document> nameDoc = userCollections.find().sort(ascending("name"))
|
||||||
|
.collation(Collation.builder().locale("en").build());
|
||||||
|
MongoCursor<Document> cursor = nameDoc.cursor();
|
||||||
|
List<String> expectedNamesOrdering = Arrays.asList("aen", "Aen", "ben", "Ben", "cen", "Cen");
|
||||||
|
List<String> actualNamesOrdering = new ArrayList<>();
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
Document document = cursor.next();
|
||||||
|
actualNamesOrdering.add(document.get("name").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(expectedNamesOrdering, actualNamesOrdering);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenMongoCollection_whenUsingFindWithSortAndAggregate_caseIsNotConsidered() {
|
||||||
|
|
||||||
|
Bson projectBson = project(
|
||||||
|
Projections.fields(
|
||||||
|
Projections.include("name", "surname"),
|
||||||
|
Projections.computed("lowerName", Projections.computed("$toLower", "$name"))));
|
||||||
|
|
||||||
|
AggregateIterable<Document> nameDoc = userCollections.aggregate(
|
||||||
|
Arrays.asList(projectBson,
|
||||||
|
sort(Sorts.ascending("lowerName"))));
|
||||||
|
|
||||||
|
MongoCursor<Document> cursor = nameDoc.cursor();
|
||||||
|
|
||||||
|
List<String> expectedNamesOrdering = Arrays.asList("aen", "Aen", "ben", "Ben", "cen", "Cen");
|
||||||
|
List<String> actualNamesOrdering = new ArrayList<>();
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
Document document = cursor.next();
|
||||||
|
actualNamesOrdering.add(document.get("name").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(expectedNamesOrdering, actualNamesOrdering);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -43,6 +43,7 @@
|
||||||
<module>java-jpa-2</module> <!-- long running -->
|
<module>java-jpa-2</module> <!-- long running -->
|
||||||
<module>java-jpa-3</module>
|
<module>java-jpa-3</module>
|
||||||
<module>java-mongodb</module> <!-- long running -->
|
<module>java-mongodb</module> <!-- long running -->
|
||||||
|
<module>java-mongodb-2</module> <!-- long running -->
|
||||||
<module>jnosql</module> <!-- long running -->
|
<module>jnosql</module> <!-- long running -->
|
||||||
<module>jooq</module>
|
<module>jooq</module>
|
||||||
<module>jpa-hibernate-cascade-type</module>
|
<module>jpa-hibernate-cascade-type</module>
|
||||||
|
@ -104,4 +105,4 @@
|
||||||
<postgresql.version>42.2.20</postgresql.version>
|
<postgresql.version>42.2.20</postgresql.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -36,4 +36,4 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -19,6 +19,7 @@ public class TodoDatasourceConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
|
@ConfigurationProperties("spring.datasource.todos.hikari")
|
||||||
public DataSource todosDataSource() {
|
public DataSource todosDataSource() {
|
||||||
return todosDataSourceProperties()
|
return todosDataSourceProperties()
|
||||||
.initializeDataSourceBuilder()
|
.initializeDataSourceBuilder()
|
||||||
|
|
|
@ -3,6 +3,7 @@ spring.datasource.todos.url=jdbc:h2:mem:todos
|
||||||
spring.datasource.todos.username=sa
|
spring.datasource.todos.username=sa
|
||||||
spring.datasource.todos.password=null
|
spring.datasource.todos.password=null
|
||||||
spring.datasource.todos.driverClassName=org.h2.Driver
|
spring.datasource.todos.driverClassName=org.h2.Driver
|
||||||
|
spring.datasource.todos.hikari.connectionTimeout=44444
|
||||||
spring.datasource.topics.url=jdbc:h2:mem:topics
|
spring.datasource.topics.url=jdbc:h2:mem:topics
|
||||||
spring.datasource.topics.username=sa
|
spring.datasource.topics.username=sa
|
||||||
spring.datasource.topics.password=null
|
spring.datasource.topics.password=null
|
||||||
|
|
|
@ -29,4 +29,4 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -107,22 +107,22 @@
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>${h2.version}</version>
|
<version>${h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>${com.sun.xml.version}</version>
|
<version>${com.sun.xml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
<version>${javax.xml.bind.version}</version>
|
<version>${javax.xml.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>${com.sun.xml.version}</version>
|
<version>${com.sun.xml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -1206,6 +1206,7 @@
|
||||||
<module>wicket</module>
|
<module>wicket</module>
|
||||||
<module>wildfly</module>
|
<module>wildfly</module>
|
||||||
<module>xml</module>
|
<module>xml</module>
|
||||||
|
<module>xml-2</module>
|
||||||
<module>xstream</module>
|
<module>xstream</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,4 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -10,9 +10,8 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>reactive-systems</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../../parent-boot-2</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>reactive-systems</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../../parent-boot-2</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>reactive-systems</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../../parent-boot-2</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-2</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -41,4 +41,5 @@
|
||||||
<properties>
|
<properties>
|
||||||
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -16,7 +16,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-1</relativePath>
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/output/
|
|
@ -44,6 +44,12 @@
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.camel</groupId>
|
||||||
|
<artifactId>camel-test-spring-junit5</artifactId>
|
||||||
|
<version>${camel.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -57,6 +63,9 @@
|
||||||
<goals>
|
<goals>
|
||||||
<goal>repackage</goal>
|
<goal>repackage</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.baeldung.camel.boot.testing.GreetingsFileSpringApplication</mainClass>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.baeldung.camel.boot.testing;
|
||||||
|
|
||||||
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GreetingsFileRouter extends RouteBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure() throws Exception {
|
||||||
|
|
||||||
|
from("direct:start")
|
||||||
|
.routeId("greetings-route")
|
||||||
|
.setBody(constant("Hello Baeldung Readers!"))
|
||||||
|
.to("file:output");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.baeldung.camel.boot.testing;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class GreetingsFileSpringApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(GreetingsFileSpringApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.camel.boot.testing;
|
||||||
|
|
||||||
|
import org.apache.camel.EndpointInject;
|
||||||
|
import org.apache.camel.ProducerTemplate;
|
||||||
|
import org.apache.camel.component.mock.MockEndpoint;
|
||||||
|
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
||||||
|
import org.apache.camel.test.spring.junit5.MockEndpoints;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@CamelSpringBootTest
|
||||||
|
@MockEndpoints("file:output")
|
||||||
|
class GreetingsFileRouterUnitTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProducerTemplate template;
|
||||||
|
|
||||||
|
@EndpointInject("mock:file:output")
|
||||||
|
private MockEndpoint mock;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenSendBody_thenGreetingReceivedSuccessfully() throws InterruptedException {
|
||||||
|
mock.expectedBodiesReceived("Hello Baeldung Readers!");
|
||||||
|
|
||||||
|
template.sendBody("direct:start", null);
|
||||||
|
|
||||||
|
mock.assertIsSatisfied();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-boot-multiple-datasources</artifactId>
|
<artifactId>spring-boot-multiple-datasources</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
@ -55,4 +55,4 @@
|
||||||
<spring-boot.version>2.6.3</spring-boot.version>
|
<spring-boot.version>2.6.3</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,3 @@
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Set List of Objects in Swagger API Response](https://www.baeldung.com/java-swagger-set-list-response)
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.baeldung.swaggerresponseapi;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SwaggerResponseApiApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SwaggerResponseApiApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.baeldung.swaggerresponseapi.controller;
|
||||||
|
|
||||||
|
import com.baeldung.swaggerresponseapi.model.Product;
|
||||||
|
import com.baeldung.swaggerresponseapi.service.ProductService;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class ProductController {
|
||||||
|
private final ProductService productService;
|
||||||
|
|
||||||
|
public ProductController(ProductService productService) {
|
||||||
|
this.productService = productService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
public Product addProduct(@RequestBody Product product) {
|
||||||
|
return productService.addProducts(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiResponses(value = { @ApiResponse(content = { @Content(mediaType = "application/json",
|
||||||
|
array = @ArraySchema(schema = @Schema(implementation = Product.class))) }) })
|
||||||
|
@GetMapping("/products")
|
||||||
|
public List<Product> getProductsList() {
|
||||||
|
return productService.getProductsList();
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue