Merge branch 'master' of https://github.com/vikasrajput6035/tutorials into BAEL-3832
This commit is contained in:
commit
4ff2eadbad
|
@ -10,3 +10,4 @@ This module contains articles about searching algorithms.
|
|||
- [String Search Algorithms for Large Texts](https://www.baeldung.com/java-full-text-search-algorithms)
|
||||
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](https://www.baeldung.com/java-monte-carlo-tree-search)
|
||||
- [Range Search Algorithm in Java](https://www.baeldung.com/java-range-search)
|
||||
- [Fast Pattern Matching of Strings Using Suffix Tree](https://www.baeldung.com/java-pattern-matching-suffix-tree)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Introduction to Apache Beam](https://www.baeldung.com/apache-beam)
|
|
@ -5,3 +5,5 @@ This module contains articles about Java 14.
|
|||
### Relevant articles
|
||||
|
||||
- [Guide to the @Serial Annotation in Java 14](https://www.baeldung.com/java-14-serial-annotation)
|
||||
- [Java Text Blocks](https://www.baeldung.com/java-text-blocks)
|
||||
- [Pattern Matching for instanceof in Java 14](https://www.baeldung.com/java-pattern-matching-instanceof)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals)
|
|
@ -7,3 +7,5 @@ This module contains articles about core java exceptions
|
|||
- [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice)
|
||||
- [Wrapping vs Rethrowing Exceptions in Java](https://www.baeldung.com/java-wrapping-vs-rethrowing-exceptions)
|
||||
- [java.net.UnknownHostException: Invalid Hostname for Server](https://www.baeldung.com/java-unknownhostexception)
|
||||
- [How to Handle Java SocketException](https://www.baeldung.com/java-socketexception)
|
||||
- [Java Suppressed Exceptions](https://www.baeldung.com/java-suppressed-exceptions)
|
||||
|
|
|
@ -47,6 +47,14 @@
|
|||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.tomakehurst/wiremock -->
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<version>2.26.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.baeldung.blockingnonblocking;
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.Socket;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BlockingClientUnitTest {
|
||||
private static final String REQUESTED_RESOURCE = "/test.json";
|
||||
|
||||
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
stubFor(get(urlEqualTo(REQUESTED_RESOURCE)).willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withBody("{ \"response\" : \"It worked!\" }\r\n\r\n")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenSuccess() throws IOException {
|
||||
// given an IO socket and somewhere to store our result
|
||||
Socket socket = new Socket("localhost", wireMockRule.port());
|
||||
StringBuilder ourStore = new StringBuilder();
|
||||
|
||||
// when we write and read (using try-with-resources so our resources are auto-closed)
|
||||
try (InputStream serverInput = socket.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput));
|
||||
OutputStream clientOutput = socket.getOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(clientOutput))) {
|
||||
writer.print("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n");
|
||||
writer.flush(); // important - without this the request is never sent, and the test will hang on readLine()
|
||||
|
||||
for (String line; (line = reader.readLine()) != null; ) {
|
||||
ourStore.append(line);
|
||||
ourStore.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
// then we read and saved our data
|
||||
assertTrue(ourStore
|
||||
.toString()
|
||||
.contains("It worked!"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.baeldung.blockingnonblocking;
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class NonBlockingClientUnitTest {
|
||||
private String REQUESTED_RESOURCE = "/test.json";
|
||||
|
||||
@Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
stubFor(get(urlEqualTo(REQUESTED_RESOURCE)).willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withBody("{ \"response\" : \"It worked!\" }")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenJavaNIOSocketChannel_whenReadingAndWritingWithBuffers_thenSuccess() throws IOException {
|
||||
// given a NIO SocketChannel and a charset
|
||||
InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port());
|
||||
SocketChannel socketChannel = SocketChannel.open(address);
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
|
||||
// when we write and read using buffers
|
||||
socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n")));
|
||||
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(8192); // or allocateDirect if we need direct memory access
|
||||
CharBuffer charBuffer = CharBuffer.allocate(8192);
|
||||
CharsetDecoder charsetDecoder = charset.newDecoder();
|
||||
StringBuilder ourStore = new StringBuilder();
|
||||
while (socketChannel.read(byteBuffer) != -1 || byteBuffer.position() > 0) {
|
||||
byteBuffer.flip();
|
||||
storeBufferContents(byteBuffer, charBuffer, charsetDecoder, ourStore);
|
||||
byteBuffer.compact();
|
||||
}
|
||||
socketChannel.close();
|
||||
|
||||
// then we read and saved our data
|
||||
assertTrue(ourStore
|
||||
.toString()
|
||||
.contains("It worked!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenJavaNIOSocketChannel_whenReadingAndWritingWithSmallBuffers_thenSuccess() throws IOException {
|
||||
// given a NIO SocketChannel and a charset
|
||||
InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port());
|
||||
SocketChannel socketChannel = SocketChannel.open(address);
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
|
||||
// when we write and read using buffers that are too small for our message
|
||||
socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n")));
|
||||
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access
|
||||
CharBuffer charBuffer = CharBuffer.allocate(8);
|
||||
CharsetDecoder charsetDecoder = charset.newDecoder();
|
||||
StringBuilder ourStore = new StringBuilder();
|
||||
while (socketChannel.read(byteBuffer) != -1 || byteBuffer.position() > 0) {
|
||||
byteBuffer.flip();
|
||||
storeBufferContents(byteBuffer, charBuffer, charsetDecoder, ourStore);
|
||||
byteBuffer.compact();
|
||||
}
|
||||
socketChannel.close();
|
||||
|
||||
// then we read and saved our data
|
||||
assertTrue(ourStore
|
||||
.toString()
|
||||
.contains("It worked!"));
|
||||
}
|
||||
|
||||
void storeBufferContents(ByteBuffer byteBuffer, CharBuffer charBuffer, CharsetDecoder charsetDecoder, StringBuilder ourStore) {
|
||||
charsetDecoder.decode(byteBuffer, charBuffer, true);
|
||||
charBuffer.flip();
|
||||
ourStore.append(charBuffer);
|
||||
charBuffer.clear();
|
||||
}
|
||||
|
||||
}
|
|
@ -9,4 +9,5 @@ This module contains articles about core features in the Java language
|
|||
- [Java Default Parameters Using Method Overloading](https://www.baeldung.com/java-default-parameters-method-overloading)
|
||||
- [How to Return Multiple Values From a Java Method](https://www.baeldung.com/java-method-return-multiple-values)
|
||||
- [Guide to the Java finally Keyword](https://www.baeldung.com/java-finally-keyword)
|
||||
- [The Java Headless Mode](https://www.baeldung.com/java-headless-mode)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-lang)
|
||||
|
|
|
@ -8,4 +8,5 @@ This module contains articles about core Java non-blocking input and output (IO)
|
|||
- [Create a Symbolic Link with Java](https://www.baeldung.com/java-symlink)
|
||||
- [Introduction to the Java NIO Selector](https://www.baeldung.com/java-nio-selector)
|
||||
- [Using Java MappedByteBuffer](https://www.baeldung.com/java-mapped-byte-buffer)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-nio)
|
||||
- [How to Lock a File in Java](https://www.baeldung.com/java-lock-files)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-nio)
|
||||
|
|
|
@ -10,3 +10,4 @@ This module contains articles about performance of Java applications
|
|||
- [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions)
|
||||
- [Monitoring Java Applications with Flight Recorder](https://www.baeldung.com/java-flight-recorder-monitoring)
|
||||
- [Branch Prediction in Java](https://www.baeldung.com/java-branch-prediction)
|
||||
- [Capturing a Java Thread Dump](https://www.baeldung.com/java-thread-dump)
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
- [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char)
|
||||
- [Pre-compile Regex Patterns Into Pattern Objects](https://www.baeldung.com/java-regex-pre-compile)
|
||||
- [Difference Between Java Matcher find() and matches()](https://www.baeldung.com/java-matcher-find-vs-matches)
|
||||
- [How to Use Regular Expressions to Replace Tokens in Strings](https://www.baeldung.com/java-regex-token-replacement)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Guide To The Java Authentication And Authorization Service (JAAS)](https://www.baeldung.com/java-authentication-authorization-service)
|
|
@ -10,4 +10,5 @@ This module contains articles about string operations.
|
|||
- [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase)
|
||||
- [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching)
|
||||
- [L-Trim and R-Trim in Java](https://www.baeldung.com/l-trim-and-r-trim-in-java)
|
||||
- [L-Trim and R-Trim Alternatives in Java](https://www.baeldung.com/java-trim-alternatives)
|
||||
- More articles: [[<-- prev]](../core-java-string-operations)
|
||||
|
|
|
@ -9,3 +9,4 @@ This module contains articles about data structures in Java
|
|||
- [Circular Linked List Java Implementation](https://www.baeldung.com/java-circular-linked-list)
|
||||
- [How to Print a Binary Tree Diagram](https://www.baeldung.com/java-print-binary-tree-diagram)
|
||||
- [Introduction to Big Queue](https://www.baeldung.com/java-big-queue)
|
||||
- [Guide to AVL Trees in Java](https://www.baeldung.com/java-avl-trees)
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
## Relevant Articles
|
||||
### Relevant Articles:
|
||||
|
||||
- [DDD Bounded Contexts and Java Modules](https://www.baeldung.com/java-modules-ddd-bounded-contexts)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [What’s New in Gradle 6.0](https://www.baeldung.com/gradle-6-features)
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Converting Gradle Build File to Maven POM](https://www.baeldung.com/gradle-build-to-maven-pom)
|
|
@ -13,4 +13,4 @@ This module contains articles about Gson
|
|||
- [Convert String to JsonObject with Gson](https://www.baeldung.com/gson-string-to-jsonobject)
|
||||
- [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field)
|
||||
- [Serializing and Deserializing a List with Gson](https://www.baeldung.com/gson-list)
|
||||
|
||||
- [Compare Two JSON Objects with Gson](https://www.baeldung.com/gson-compare-json-objects)
|
||||
|
|
|
@ -4,3 +4,5 @@ This module contains articles about image processing.
|
|||
|
||||
### Relevant Articles:
|
||||
- [Working with Images in Java](https://www.baeldung.com/java-images)
|
||||
- [Intro to OpenCV with Java](https://www.baeldung.com/java-opencv)
|
||||
- [Optical Character Recognition with Tesseract](https://www.baeldung.com/java-ocr-tesseract)
|
||||
|
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
- [Generating Random Numbers](https://www.baeldung.com/java-generating-random-numbers)
|
||||
- [Convert Double to Long in Java](https://www.baeldung.com/java-convert-double-long)
|
||||
- [Check for null Before Calling Parse in Double.parseDouble](https://www.baeldung.com/java-check-null-parse-double)
|
||||
|
|
|
@ -12,7 +12,9 @@ import javax.batch.runtime.StepExecution;
|
|||
import com.baeldung.batch.understanding.BatchTestHelper;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
@Disabled("Should be fixed in BAEL-3812")
|
||||
class CustomCheckPointUnitTest {
|
||||
@Test
|
||||
public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception {
|
||||
|
|
|
@ -13,7 +13,9 @@ import javax.batch.runtime.JobExecution;
|
|||
import javax.batch.runtime.StepExecution;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
@Disabled("Should be fixed in BAEL-3812")
|
||||
class JobSequenceUnitTest {
|
||||
@Test
|
||||
public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception {
|
||||
|
|
|
@ -14,7 +14,9 @@ import javax.batch.runtime.Metric;
|
|||
import javax.batch.runtime.StepExecution;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
@Disabled("Should be fixed in BAEL-3812")
|
||||
class SimpleChunkUnitTest {
|
||||
@Test
|
||||
public void givenChunk_thenBatch_CompletesWithSucess() throws Exception {
|
||||
|
|
|
@ -4,3 +4,4 @@ This module contains articles about JSON.
|
|||
|
||||
### Relevant Articles:
|
||||
- [Introduction to Jsoniter](https://www.baeldung.com/java-jsoniter)
|
||||
- [Introduction to Moshi Json](https://www.baeldung.com/java-json-moshi)
|
||||
|
|
|
@ -12,3 +12,7 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
|
|||
- [Guide to the Cactoos Library](https://www.baeldung.com/java-cactoos)
|
||||
- [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline)
|
||||
- [Introduction to cache2k](https://www.baeldung.com/java-cache2k)
|
||||
- [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects)
|
||||
- [Introduction to Takes](https://www.baeldung.com/java-takes)
|
||||
- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway)
|
||||
|
||||
|
|
|
@ -94,6 +94,23 @@
|
|||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity-engine-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.uber.nullaway</groupId>
|
||||
<artifactId>nullaway</artifactId>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac-errorprone</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<!-- override plexus-compiler-javac-errorprone's dependency on
|
||||
Error Prone with the latest version -->
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
@ -130,6 +147,45 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5</version>
|
||||
<configuration>
|
||||
<compilerId>javac-with-errorprone</compilerId>
|
||||
<forceJavacCompilerUse>true</forceJavacCompilerUse>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showWarnings>true</showWarnings>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>com.uber.nullaway</groupId>
|
||||
<artifactId>nullaway</artifactId>
|
||||
<version>0.3.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<!-- NullAway will warn by default, uncomment the next line to make the build fail -->
|
||||
<!-- <arg>-Xep:NullAway:ERROR</arg> -->
|
||||
<arg>-XepExcludedPaths:(.*)/test/.*|(.*)/jcabi/.*</arg>
|
||||
<arg>-XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac-errorprone</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<!-- override plexus-compiler-javac-errorprone's dependency on
|
||||
Error Prone with the latest version -->
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>2.3.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.baeldung.nullaway;
|
||||
|
||||
import com.baeldung.distinct.Person;
|
||||
|
||||
public class NullAwayExample {
|
||||
|
||||
/*
|
|
@ -0,0 +1,65 @@
|
|||
package com.baeldung.nullaway;
|
||||
|
||||
public class Person {
|
||||
int age;
|
||||
String name;
|
||||
String email;
|
||||
|
||||
public Person(int age, String name, String email) {
|
||||
super();
|
||||
this.age = age;
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Person [age=");
|
||||
builder.append(age);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", email=");
|
||||
builder.append(email);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((email == null) ? 0 : email.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Person other = (Person) obj;
|
||||
if (email == null) {
|
||||
if (other.email != null)
|
||||
return false;
|
||||
} else if (!email.equals(other.email))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,3 +9,4 @@ This module contains articles about IO data processing libraries.
|
|||
- [Introduction To OpenCSV](https://www.baeldung.com/opencsv)
|
||||
- [Interact with Google Sheets from Java](https://www.baeldung.com/google-sheets-java-client)
|
||||
- [Introduction To Docx4J](https://www.baeldung.com/docx4j)
|
||||
- [Breaking YAML Strings Over Multiple Lines](https://www.baeldung.com/yaml-multi-line)
|
||||
|
|
|
@ -435,23 +435,6 @@
|
|||
<artifactId>reflections</artifactId>
|
||||
<version>${reflections.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.uber.nullaway</groupId>
|
||||
<artifactId>nullaway</artifactId>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac-errorprone</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<!-- override plexus-compiler-javac-errorprone's dependency on
|
||||
Error Prone with the latest version -->
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
@ -569,46 +552,6 @@
|
|||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5</version>
|
||||
<configuration>
|
||||
<compilerId>javac-with-errorprone</compilerId>
|
||||
<forceJavacCompilerUse>true</forceJavacCompilerUse>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showWarnings>true</showWarnings>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>com.uber.nullaway</groupId>
|
||||
<artifactId>nullaway</artifactId>
|
||||
<version>0.3.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<!-- NullAway will warn by default, uncomment the next line to make the build fail -->
|
||||
<!-- <arg>-Xep:NullAway:ERROR</arg> -->
|
||||
<arg>-XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.*</arg>
|
||||
<arg>-XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-compiler-javac-errorprone</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<!-- override plexus-compiler-javac-errorprone's dependency on
|
||||
Error Prone with the latest version -->
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Introduction to Open Liberty](https://www.baeldung.com/java-open-liberty)
|
|
@ -9,3 +9,4 @@ This module contains articles about MongoDB in Java.
|
|||
- [MongoDB BSON Guide](https://www.baeldung.com/mongodb-bson)
|
||||
- [Geospatial Support in MongoDB](https://www.baeldung.com/mongodb-geospatial-support)
|
||||
- [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia)
|
||||
- [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations)
|
||||
|
|
|
@ -29,12 +29,30 @@
|
|||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vladmihalcea</groupId>
|
||||
<artifactId>db-util</artifactId>
|
||||
<version>${db-util.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<!-- The main class to start by executing java -jar -->
|
||||
<start-class>com.baeldung.h2db.demo.server.SpringBootApp</start-class>
|
||||
<spring-boot.version>2.0.4.RELEASE</spring-boot.version>
|
||||
<hibernate.version>5.3.11.Final</hibernate.version>
|
||||
<db-util.version>1.0.4</db-util.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
public class LazyLoadNoTransSpringBootApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LazyLoadNoTransSpringBootApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.config;
|
||||
|
||||
import net.ttddyy.dsproxy.listener.DataSourceQueryCountListener;
|
||||
import net.ttddyy.dsproxy.listener.logging.CommonsQueryLoggingListener;
|
||||
import net.ttddyy.dsproxy.listener.logging.DefaultQueryLogEntryCreator;
|
||||
import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel;
|
||||
import net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener;
|
||||
import net.ttddyy.dsproxy.support.ProxyDataSource;
|
||||
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Component
|
||||
public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
if (bean instanceof DataSource && !(bean instanceof ProxyDataSource)) {
|
||||
// Instead of directly returning a less specific datasource bean
|
||||
// (e.g.: HikariDataSource -> DataSource), return a proxy object.
|
||||
// See following links for why:
|
||||
// https://stackoverflow.com/questions/44237787/how-to-use-user-defined-database-proxy-in-datajpatest
|
||||
// https://gitter.im/spring-projects/spring-boot?at=5983602d2723db8d5e70a904
|
||||
// http://blog.arnoldgalovics.com/2017/06/26/configuring-a-datasource-proxy-in-spring-boot/
|
||||
final ProxyFactory factory = new ProxyFactory(bean);
|
||||
factory.setProxyTargetClass(true);
|
||||
factory.addAdvice(new ProxyDataSourceInterceptor((DataSource) bean));
|
||||
return factory.getProxy();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
private static class ProxyDataSourceInterceptor implements MethodInterceptor {
|
||||
private final DataSource dataSource;
|
||||
|
||||
public ProxyDataSourceInterceptor(final DataSource dataSource) {
|
||||
this.dataSource = ProxyDataSourceBuilder.create(dataSource)
|
||||
.name("MyDS")
|
||||
.multiline()
|
||||
.logQueryBySlf4j(SLF4JLogLevel.INFO)
|
||||
.listener(new DataSourceQueryCountListener())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
final Method proxyMethod = ReflectionUtils.findMethod(this.dataSource.getClass(),
|
||||
invocation.getMethod().getName());
|
||||
if (proxyMethod != null) {
|
||||
return proxyMethod.invoke(this.dataSource, invocation.getArguments());
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Immutable
|
||||
public class Document {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Long userId;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Immutable
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String comment;
|
||||
|
||||
@OneToMany(mappedBy = "userId")
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<Document> docs = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.repository;
|
||||
|
||||
import com.baeldung.h2db.lazy_load_no_trans.entity.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.h2db.lazy_load_no_trans.service;
|
||||
|
||||
import com.baeldung.h2db.lazy_load_no_trans.entity.User;
|
||||
import com.baeldung.h2db.lazy_load_no_trans.repository.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Service
|
||||
public class ServiceLayer {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public long countAllDocsTransactional() {
|
||||
return countAllDocs();
|
||||
}
|
||||
|
||||
public long countAllDocsNonTransactional() {
|
||||
return countAllDocs();
|
||||
}
|
||||
|
||||
private long countAllDocs() {
|
||||
return userRepository.findAll()
|
||||
.stream()
|
||||
.map(User::getDocs)
|
||||
.mapToLong(Collection::size)
|
||||
.sum();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
spring.datasource.url=jdbc:h2:mem:mydb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2-console
|
||||
|
||||
logging.level.org.hibernate.SQL=INFO
|
||||
logging.level.org.hibernate.type=TRACE
|
||||
spring.jpa.properties.hibernate.validator.apply_to_ddl=false
|
||||
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=false
|
||||
spring.jpa.open-in-view=false
|
|
@ -0,0 +1,13 @@
|
|||
spring.datasource.url=jdbc:h2:mem:mydb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2-console
|
||||
|
||||
logging.level.org.hibernate.SQL=INFO
|
||||
logging.level.org.hibernate.type=TRACE
|
||||
spring.jpa.properties.hibernate.validator.apply_to_ddl=false
|
||||
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
|
||||
spring.jpa.open-in-view=false
|
|
@ -10,4 +10,17 @@ CREATE TABLE billionaires (
|
|||
INSERT INTO billionaires (first_name, last_name, career) VALUES
|
||||
('Aliko', 'Dangote', 'Billionaire Industrialist'),
|
||||
('Bill', 'Gates', 'Billionaire Tech Entrepreneur'),
|
||||
('Folrunsho', 'Alakija', 'Billionaire Oil Magnate');
|
||||
('Folrunsho', 'Alakija', 'Billionaire Oil Magnate');
|
||||
|
||||
insert into USER values (101, 'user1', 'comment1');
|
||||
insert into USER values (102, 'user2', 'comment2');
|
||||
insert into USER values (103, 'user3', 'comment3');
|
||||
insert into USER values (104, 'user4', 'comment4');
|
||||
insert into USER values (105, 'user5', 'comment5');
|
||||
|
||||
insert into DOCUMENT values (1, 'doc1', 101);
|
||||
insert into DOCUMENT values (2, 'doc2', 101);
|
||||
insert into DOCUMENT values (3, 'doc3', 101);
|
||||
insert into DOCUMENT values (4, 'doc4', 101);
|
||||
insert into DOCUMENT values (5, 'doc5', 102);
|
||||
insert into DOCUMENT values (6, 'doc6', 102);
|
|
@ -0,0 +1,41 @@
|
|||
package com.baeldung.lazy_load_no_trans;
|
||||
|
||||
import com.baeldung.h2db.lazy_load_no_trans.LazyLoadNoTransSpringBootApplication;
|
||||
import com.baeldung.h2db.lazy_load_no_trans.service.ServiceLayer;
|
||||
import com.vladmihalcea.sql.SQLStatementCountValidator;
|
||||
import org.hibernate.LazyInitializationException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = LazyLoadNoTransSpringBootApplication.class)
|
||||
@ActiveProfiles("lazy-load-no-trans-off")
|
||||
public class LazyLoadNoTransPropertyOffIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private ServiceLayer serviceLayer;
|
||||
|
||||
private static final long EXPECTED_DOCS_COLLECTION_SIZE = 6;
|
||||
|
||||
@Test(expected = LazyInitializationException.class)
|
||||
public void whenCallNonTransactionalMethodWithPropertyOff_thenThrowException() {
|
||||
serviceLayer.countAllDocsNonTransactional();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallTransactionalMethodWithPropertyOff_thenTestPass() {
|
||||
SQLStatementCountValidator.reset();
|
||||
|
||||
long docsCount = serviceLayer.countAllDocsTransactional();
|
||||
|
||||
assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount);
|
||||
|
||||
SQLStatementCountValidator.assertSelectCount(2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.baeldung.lazy_load_no_trans;
|
||||
|
||||
import com.baeldung.h2db.lazy_load_no_trans.LazyLoadNoTransSpringBootApplication;
|
||||
import com.baeldung.h2db.lazy_load_no_trans.service.ServiceLayer;
|
||||
import com.vladmihalcea.sql.SQLStatementCountValidator;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = LazyLoadNoTransSpringBootApplication.class)
|
||||
@ActiveProfiles("lazy-load-no-trans-on")
|
||||
public class LazyLoadNoTransPropertyOnIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private ServiceLayer serviceLayer;
|
||||
|
||||
private static final long EXPECTED_DOCS_COLLECTION_SIZE = 6;
|
||||
private static final long EXPECTED_USERS_COUNT = 5;
|
||||
|
||||
@Test
|
||||
public void whenCallNonTransactionalMethodWithPropertyOn_thenGetNplusOne() {
|
||||
SQLStatementCountValidator.reset();
|
||||
|
||||
long docsCount = serviceLayer.countAllDocsNonTransactional();
|
||||
|
||||
assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount);
|
||||
|
||||
SQLStatementCountValidator.assertSelectCount(EXPECTED_USERS_COUNT + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCallTransactionalMethodWithPropertyOn_thenTestPass() {
|
||||
SQLStatementCountValidator.reset();
|
||||
|
||||
long docsCount = serviceLayer.countAllDocsTransactional();
|
||||
|
||||
assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount);
|
||||
|
||||
SQLStatementCountValidator.assertSelectCount(2);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
- [Programmatic Transaction Management in Spring](https://www.baeldung.com/spring-programmatic-transaction-management)
|
||||
- [JPA Entity Lifecycle Events](https://www.baeldung.com/jpa-entity-lifecycle-events)
|
||||
- [Working with Lazy Element Collections in JPA](https://www.baeldung.com/java-jpa-lazy-collections)
|
||||
- [Calling Stored Procedures from Spring Data JPA Repositories](https://www.baeldung.com/spring-data-jpa-stored-procedures)
|
||||
|
||||
### Eclipse Config
|
||||
After importing the project into Eclipse, you may see the following error:
|
||||
|
|
|
@ -16,8 +16,7 @@ public class MovieDatabaseNeo4jConfiguration {
|
|||
|
||||
@Bean
|
||||
public org.neo4j.ogm.config.Configuration getConfiguration() {
|
||||
org.neo4j.ogm.config.Configuration config = new Builder().uri(URL).build();
|
||||
return config;
|
||||
return new Builder().uri(URL).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
- [Introduction to Spring Data Redis](https://www.baeldung.com/spring-data-redis-tutorial)
|
||||
- [PubSub Messaging with Spring Data Redis](https://www.baeldung.com/spring-data-redis-pub-sub)
|
||||
- [An Introduction to Spring Data Redis Reactive](https://www.baeldung.com/spring-data-redis-reactive)
|
||||
- [Delete Everything in Redis](https://www.baeldung.com/redis-delete-data)
|
||||
|
||||
### Build the Project with Tests Running
|
||||
```
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Asynchronous HTTP Programming with Play Framework](https://www.baeldung.com/java-play-asynchronous-http-programming)
|
|
@ -16,3 +16,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Spring Assert Statements](https://www.baeldung.com/spring-assert)
|
||||
- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari)
|
||||
- [Difference between \<context:annotation-config> vs \<context:component-scan>](https://www.baeldung.com/spring-contextannotation-contextcomponentscan)
|
||||
- [Finding the Spring Version](https://www.baeldung.com/spring-find-version)
|
||||
|
|
|
@ -7,3 +7,4 @@ This module contains articles about Spring with the AMQP messaging system
|
|||
- [Messaging With Spring AMQP](https://www.baeldung.com/spring-amqp)
|
||||
- [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp)
|
||||
- [Error Handling with Spring AMQP](https://www.baeldung.com/spring-amqp-error-handling)
|
||||
- [Exponential Backoff With Spring AMQP](https://www.baeldung.com/spring-amqp-exponential-backoff)
|
||||
|
|
|
@ -9,3 +9,4 @@ This module contains articles about Spring Batch
|
|||
- [How to Trigger and Stop a Scheduled Spring Batch Job](https://www.baeldung.com/spring-batch-start-stop-job)
|
||||
- [Configuring Skip Logic in Spring Batch](https://www.baeldung.com/spring-batch-skip-logic)
|
||||
- [Testing a Spring Batch Job](https://www.baeldung.com/spring-batch-testing-job)
|
||||
- [Configuring Retry Logic in Spring Batch](https://www.baeldung.com/spring-batch-retry-logic)
|
||||
|
|
|
@ -10,3 +10,4 @@ This module contains articles about bootstrapping Spring Boot applications.
|
|||
- [Deploy a Spring Boot Application to OpenShift](https://www.baeldung.com/spring-boot-deploy-openshift)
|
||||
- [Deploy a Spring Boot Application to AWS Beanstalk](https://www.baeldung.com/spring-boot-deploy-aws-beanstalk)
|
||||
- [Guide to @SpringBootConfiguration in Spring Boot](https://www.baeldung.com/springbootconfiguration-annotation)
|
||||
- [Implement Health Checks in OpenShift](https://www.baeldung.com/openshift-health-checks)
|
||||
|
|
|
@ -6,4 +6,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects.
|
|||
|
||||
- [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers)
|
||||
- [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings)
|
||||
- [Swagger @ApiParam vs @ApiModelProperty](https://www.baeldung.com/swagger-apiparam-vs-apimodelproperty)
|
||||
- More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc)
|
||||
|
|
|
@ -12,3 +12,5 @@ This module contains articles about Properties in Spring Boot.
|
|||
- [Spring YAML Configuration](https://www.baeldung.com/spring-yaml)
|
||||
- [Using Spring @Value with Defaults](https://www.baeldung.com/spring-value-defaults)
|
||||
- [How to Inject a Property Value Into a Class Not Managed by Spring?](https://www.baeldung.com/inject-properties-value-non-spring-class)
|
||||
- [Add Build Properties to a Spring Boot Application](https://www.baeldung.com/spring-boot-build-properties)
|
||||
- [IntelliJ – Cannot Resolve Spring Boot Configuration Properties Error](https://www.baeldung.com/intellij-resolve-spring-boot-configuration-properties)
|
||||
|
|
|
@ -12,3 +12,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Exclude Auto-Configuration Classes in Spring Boot Tests](https://www.baeldung.com/spring-boot-exclude-auto-configuration-test)
|
||||
- [Setting the Log Level in Spring Boot when Testing](https://www.baeldung.com/spring-boot-testing-log-level)
|
||||
- [Embedded Redis Server with Spring Boot Test](https://www.baeldung.com/spring-embedded-redis)
|
||||
- [Testing Spring Boot @ConfigurationProperties](https://www.baeldung.com/spring-boot-testing-configurationproperties)
|
||||
|
|
|
@ -5,3 +5,4 @@ This module contains articles about Spring Cloud Gateway
|
|||
### Relevant Articles:
|
||||
- [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway)
|
||||
- [Writing Custom Spring Cloud Gateway Filters](https://www.baeldung.com/spring-cloud-custom-gateway-filters)
|
||||
- [Spring Cloud Gateway Routing Predicate Factories](https://www.baeldung.com/spring-cloud-gateway-routing-predicate-factories)
|
||||
|
|
|
@ -5,3 +5,4 @@ This module contains articles about Spring with Netflix Zuul
|
|||
### Relevant Articles:
|
||||
- [Rate Limiting in Spring Cloud Netflix Zuul](https://www.baeldung.com/spring-cloud-zuul-rate-limit)
|
||||
- [Spring REST with a Zuul Proxy](https://www.baeldung.com/spring-rest-with-zuul-proxy)
|
||||
- [Modifying the Response Body in a Zuul Filter](https://www.baeldung.com/zuul-filter-modifying-response-body)
|
||||
|
|
|
@ -8,4 +8,6 @@ This module contains articles about core Spring functionality
|
|||
- [Guide to the Spring BeanFactory](https://www.baeldung.com/spring-beanfactory)
|
||||
- [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean)
|
||||
- [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections)
|
||||
- [Design Patterns in the Spring Framework](https://www.baeldung.com/spring-framework-design-patterns)
|
||||
- [Injecting a Value in a Static Field in Spring](https://www.baeldung.com/spring-inject-static-field)
|
||||
- More articles: [[<-- prev]](/spring-core-2)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Spring Bean vs. EJB – A Feature Comparison](https://www.baeldung.com/spring-bean-vs-ejb)
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers)
|
|
@ -17,6 +17,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml)
|
||||
- [Validating RequestParams and PathVariables in Spring](https://www.baeldung.com/spring-validate-requestparam-pathvariable)
|
||||
- [Debugging the Spring MVC 404 “No mapping found for HTTP request” Error](https://www.baeldung.com/spring-mvc-404-error)
|
||||
- [Getting Started with CRaSH](https://www.baeldung.com/jvm-crash-shell)
|
||||
|
||||
## Spring MVC with XML Configuration Example Project
|
||||
|
||||
|
|
|
@ -12,3 +12,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||
- [Returning Custom Status Codes from Spring Controllers](https://www.baeldung.com/spring-mvc-controller-custom-http-status-code)
|
||||
- [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping)
|
||||
- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result)
|
||||
- [Using JSON Patch in Spring REST APIs](https://www.baeldung.com/spring-rest-json-patch)
|
||||
|
|
|
@ -222,10 +222,10 @@
|
|||
</profiles>
|
||||
|
||||
<properties>
|
||||
<start-class>org.baeldung.custom.Application</start-class>
|
||||
<start-class>com.baeldung.roles.custom.Application</start-class>
|
||||
<!--If you want to run the example with the voters comment the tag
|
||||
above and uncomment the one below -->
|
||||
<!--<start-class>org.baeldung.voter.VoterApplication</start-class> -->
|
||||
<!--<start-class>com.baeldung.roles.voter.VoterApplication</start-class> -->
|
||||
|
||||
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung;
|
||||
package com.baeldung.relationships;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|||
|
||||
@SpringBootApplication
|
||||
@PropertySource({"classpath:persistence-h2.properties", "classpath:application-defaults.properties"})
|
||||
@EnableJpaRepositories(basePackages = { "com.baeldung.data.repositories" })
|
||||
@EnableJpaRepositories(basePackages = {"com.baeldung.relationships.repositories"})
|
||||
@EnableWebMvc
|
||||
@Import(SpringSecurityConfig.class)
|
||||
public class AppConfig extends WebMvcConfigurerAdapter {
|
||||
|
@ -41,7 +41,7 @@ public class AppConfig extends WebMvcConfigurerAdapter {
|
|||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
em.setDataSource(dataSource());
|
||||
em.setPackagesToScan(new String[] { "com.baeldung.models" });
|
||||
em.setPackagesToScan(new String[] { "com.baeldung.relationships.models" });
|
||||
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
|
||||
em.setJpaProperties(additionalProperties());
|
||||
return em;
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung;
|
||||
package com.baeldung.relationships;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
|
@ -18,8 +18,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||
import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.security.AuthenticationSuccessHandlerImpl;
|
||||
import com.baeldung.security.CustomUserDetailsService;
|
||||
import com.baeldung.relationships.security.AuthenticationSuccessHandlerImpl;
|
||||
import com.baeldung.relationships.security.CustomUserDetailsService;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.models;
|
||||
package com.baeldung.relationships.models;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.models;
|
||||
package com.baeldung.relationships.models;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung.data.repositories;
|
||||
package com.baeldung.relationships.repositories;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import com.baeldung.models.Tweet;
|
||||
import com.baeldung.relationships.models.Tweet;
|
||||
|
||||
public interface TweetRepository extends PagingAndSortingRepository<Tweet, Long> {
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
package com.baeldung.data.repositories;
|
||||
package com.baeldung.relationships.repositories;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baeldung.models.AppUser;
|
||||
import com.baeldung.relationships.models.AppUser;
|
||||
|
||||
public interface UserRepository extends CrudRepository<AppUser, Long> {
|
||||
AppUser findByUsername(String username);
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.security;
|
||||
package com.baeldung.relationships.security;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -8,7 +8,7 @@ import org.springframework.security.core.GrantedAuthority;
|
|||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import com.baeldung.models.AppUser;
|
||||
import com.baeldung.relationships.models.AppUser;
|
||||
|
||||
public class AppUserPrincipal implements UserDetails {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.security;
|
||||
package com.baeldung.relationships.security;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.baeldung.data.repositories.UserRepository;
|
||||
import com.baeldung.relationships.repositories.UserRepository;
|
||||
|
||||
@Component
|
||||
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.security;
|
||||
package com.baeldung.relationships.security;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
|
@ -9,8 +9,8 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.data.repositories.UserRepository;
|
||||
import com.baeldung.models.AppUser;
|
||||
import com.baeldung.relationships.repositories.UserRepository;
|
||||
import com.baeldung.relationships.models.AppUser;
|
||||
|
||||
@Service
|
||||
public class CustomUserDetailsService implements UserDetailsService {
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.util;
|
||||
package com.baeldung.relationships.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -10,8 +10,8 @@ import java.util.stream.IntStream;
|
|||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import com.baeldung.models.AppUser;
|
||||
import com.baeldung.models.Tweet;
|
||||
import com.baeldung.relationships.models.AppUser;
|
||||
import com.baeldung.relationships.models.Tweet;
|
||||
|
||||
public class DummyContentUtil {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom;
|
||||
package com.baeldung.roles.custom;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan("org.baeldung.custom")
|
||||
@ComponentScan("com.baeldung.roles.custom")
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
public class Application extends SpringBootServletInitializer {
|
||||
public static void main(String[] args) {
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.custom.config;
|
||||
package com.baeldung.roles.custom.config;
|
||||
|
||||
import org.baeldung.custom.security.CustomMethodSecurityExpressionHandler;
|
||||
import org.baeldung.custom.security.CustomPermissionEvaluator;
|
||||
import com.baeldung.roles.custom.security.CustomMethodSecurityExpressionHandler;
|
||||
import com.baeldung.roles.custom.security.CustomPermissionEvaluator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.config;
|
||||
package com.baeldung.roles.custom.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.config;
|
||||
package com.baeldung.roles.custom.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,16 +1,16 @@
|
|||
package org.baeldung.custom.persistence;
|
||||
package com.baeldung.roles.custom.persistence;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.baeldung.custom.persistence.dao.OrganizationRepository;
|
||||
import org.baeldung.custom.persistence.dao.PrivilegeRepository;
|
||||
import org.baeldung.custom.persistence.dao.UserRepository;
|
||||
import org.baeldung.custom.persistence.model.Organization;
|
||||
import org.baeldung.custom.persistence.model.Privilege;
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.dao.OrganizationRepository;
|
||||
import com.baeldung.roles.custom.persistence.dao.PrivilegeRepository;
|
||||
import com.baeldung.roles.custom.persistence.dao.UserRepository;
|
||||
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.custom.persistence.dao;
|
||||
package com.baeldung.roles.custom.persistence.dao;
|
||||
|
||||
import org.baeldung.custom.persistence.model.Organization;
|
||||
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface OrganizationRepository extends JpaRepository<Organization, Long> {
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.custom.persistence.dao;
|
||||
package com.baeldung.roles.custom.persistence.dao;
|
||||
|
||||
import org.baeldung.custom.persistence.model.Privilege;
|
||||
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.custom.persistence.dao;
|
||||
package com.baeldung.roles.custom.persistence.dao;
|
||||
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.persistence.model;
|
||||
package com.baeldung.roles.custom.persistence.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.persistence.model;
|
||||
package com.baeldung.roles.custom.persistence.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.persistence.model;
|
||||
package com.baeldung.roles.custom.persistence.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.persistence.model;
|
||||
package com.baeldung.roles.custom.persistence.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.security.access.expression.SecurityExpressionRoot;
|
||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
||||
import org.springframework.security.core.Authentication;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.security.access.PermissionEvaluator;
|
||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations;
|
||||
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import org.baeldung.custom.persistence.dao.UserRepository;
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.dao.UserRepository;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
@ -1,11 +1,11 @@
|
|||
package org.baeldung.custom.security;
|
||||
package com.baeldung.roles.custom.security;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.custom.persistence.model.Privilege;
|
||||
import org.baeldung.custom.persistence.model.User;
|
||||
import com.baeldung.roles.custom.persistence.model.Privilege;
|
||||
import com.baeldung.roles.custom.persistence.model.User;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.custom.web;
|
||||
package com.baeldung.roles.custom.web;
|
||||
|
||||
import org.baeldung.custom.persistence.dao.OrganizationRepository;
|
||||
import org.baeldung.custom.persistence.model.Foo;
|
||||
import org.baeldung.custom.persistence.model.Organization;
|
||||
import org.baeldung.custom.security.MyUserPrincipal;
|
||||
import com.baeldung.roles.custom.persistence.dao.OrganizationRepository;
|
||||
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||
import com.baeldung.roles.custom.persistence.model.Organization;
|
||||
import com.baeldung.roles.custom.security.MyUserPrincipal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.ip;
|
||||
package com.baeldung.roles.ip;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan("org.baeldung.ip")
|
||||
@ComponentScan("com.baeldung.ip")
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
public class IpApplication extends SpringBootServletInitializer {
|
||||
public static void main(String[] args) {
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.ip.config;
|
||||
package com.baeldung.roles.ip.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.ip.config;
|
||||
package com.baeldung.roles.ip.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.ip.config;
|
||||
package com.baeldung.roles.ip.config;
|
||||
|
||||
|
||||
//@Configuration
|
|
@ -1,11 +1,11 @@
|
|||
package org.baeldung.ip.web;
|
||||
package com.baeldung.roles.ip.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.baeldung.custom.persistence.model.Foo;
|
||||
import com.baeldung.roles.custom.persistence.model.Foo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.security.web.FilterChainProxy;
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.rolesauthorities;
|
||||
package com.baeldung.roles.rolesauthorities;
|
||||
|
||||
import org.baeldung.rolesauthorities.model.User;
|
||||
import org.baeldung.rolesauthorities.persistence.UserRepository;
|
||||
import com.baeldung.roles.rolesauthorities.model.User;
|
||||
import com.baeldung.roles.rolesauthorities.persistence.UserRepository;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.rolesauthorities;
|
||||
package com.baeldung.roles.rolesauthorities;
|
||||
|
||||
import java.io.IOException;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue