Merge branch 'master' into master
This commit is contained in:
commit
1539ad605b
|
@ -32,7 +32,7 @@ Running a Spring Boot module
|
||||||
====================
|
====================
|
||||||
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
|
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
|
||||||
|
|
||||||
#Running Tests
|
###Running Tests
|
||||||
|
|
||||||
The command `mvn clean install` will run the unit tests in a module.
|
The command `mvn clean install` will run the unit tests in a module.
|
||||||
To run the integration tests, use the command `mvn clean install -Pintegration-lite-first`
|
To run the integration tests, use the command `mvn clean install -Pintegration-lite-first`
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||||
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
|
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
|
||||||
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
|
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
|
||||||
- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)
|
- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.baeldung.concatenate
|
||||||
|
|
||||||
|
class Wonder {
|
||||||
|
|
||||||
|
String numOfWonder = 'seven'
|
||||||
|
|
||||||
|
String operator_plus() {
|
||||||
|
return 'The ' + numOfWonder + ' wonders of the world'
|
||||||
|
}
|
||||||
|
|
||||||
|
String operator_left() {
|
||||||
|
return 'The ' << numOfWonder << ' wonders of ' << 'the world'
|
||||||
|
}
|
||||||
|
|
||||||
|
String interpolation_one() {
|
||||||
|
return "The $numOfWonder wonders of the world"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String interpolation_two() {
|
||||||
|
return "The ${numOfWonder} wonders of the world"
|
||||||
|
}
|
||||||
|
|
||||||
|
String multilineString() {
|
||||||
|
return """
|
||||||
|
There are $numOfWonder wonders of the world.
|
||||||
|
Can you name them all?
|
||||||
|
1. The Great Pyramid of Giza
|
||||||
|
2. Hanging Gardens of Babylon
|
||||||
|
3. Colossus of Rhode
|
||||||
|
4. Lighthouse of Alexendra
|
||||||
|
5. Temple of Artemis
|
||||||
|
6. Status of Zeus at Olympia
|
||||||
|
7. Mausoleum at Halicarnassus
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
String method_concat() {
|
||||||
|
return 'The '.concat(numOfWonder).concat(' wonders of the world')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
String method_builder() {
|
||||||
|
return new StringBuilder()
|
||||||
|
.append('The ').append(numOfWonder).append(' wonders of the world')
|
||||||
|
}
|
||||||
|
|
||||||
|
String method_buffer() {
|
||||||
|
return new StringBuffer()
|
||||||
|
.append('The ').append(numOfWonder).append(' wonders of the world')
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.baeldung.concatenate
|
||||||
|
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import static org.junit.Assert.*
|
||||||
|
|
||||||
|
class WonderUnitTest {
|
||||||
|
|
||||||
|
static final String EXPECTED_SINGLE_LINE = "The seven wonders of the world"
|
||||||
|
|
||||||
|
Wonder wonder
|
||||||
|
|
||||||
|
@Before
|
||||||
|
void before() {
|
||||||
|
wonder = new Wonder()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingOperatorPlus_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_plus())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingOperatorLeft_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_left())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingInterpolationOne_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_one())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingInterpolationTwo_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_two())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingMultiline_thenConcatCorrectly() {
|
||||||
|
def expectedMultiline = """
|
||||||
|
There are seven wonders of the world.
|
||||||
|
Can you name them all?
|
||||||
|
1. The Great Pyramid of Giza
|
||||||
|
2. Hanging Gardens of Babylon
|
||||||
|
3. Colossus of Rhode
|
||||||
|
4. Lighthouse of Alexendra
|
||||||
|
5. Temple of Artemis
|
||||||
|
6. Status of Zeus at Olympia
|
||||||
|
7. Mausoleum at Halicarnassus
|
||||||
|
"""
|
||||||
|
assertEquals(expectedMultiline, wonder.multilineString())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingMethodConcat_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_concat())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingMethodBuilder_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_builder())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenUsingMethodBuffer_thenConcatCorrectly() {
|
||||||
|
assertEquals(EXPECTED_SINGLE_LINE, wonder.method_buffer())
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [String API Updates in Java 12](https://www.baeldung.com/java12-string-api)
|
|
@ -259,4 +259,15 @@ public class OptionalUnitTest {
|
||||||
LOG.debug("Getting default value...");
|
LOG.debug("Getting default value...");
|
||||||
return "Default Value";
|
return "Default Value";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncomment code when code base is compatiable with Java 11
|
||||||
|
// @Test
|
||||||
|
// public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() {
|
||||||
|
// Optional<String> opt = Optional.of("Baeldung");
|
||||||
|
// assertFalse(opt.isEmpty());
|
||||||
|
//
|
||||||
|
// opt = Optional.ofNullable(null);
|
||||||
|
// assertTrue(opt.isEmpty());
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,7 +42,7 @@ public class CoreJavaCollectionsUnitTest {
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test(expected = UnsupportedOperationException.class)
|
||||||
public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() {
|
public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() {
|
||||||
final List<String> list = new ArrayList<String>(Arrays.asList("one", "two", "three"));
|
final List<String> list = new ArrayList<String>(Arrays.asList("one", "two", "three"));
|
||||||
final ImmutableList<Object> unmodifiableList = ImmutableList.builder().addAll(list).build();
|
final ImmutableList<String> unmodifiableList = ImmutableList.<String>builder().addAll(list).build();
|
||||||
unmodifiableList.add("four");
|
unmodifiableList.add("four");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,3 +17,4 @@
|
||||||
- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
|
- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
|
||||||
- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety)
|
- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety)
|
||||||
- [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread)
|
- [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread)
|
||||||
|
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch)
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Why Do Local Variables Used in Lambdas Have to Be Final or Effectively Final?](https://www.baeldung.com/java-lambda-effectively-final-local-variables)
|
|
@ -4,3 +4,4 @@
|
||||||
- [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring)
|
- [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring)
|
||||||
- [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords)
|
- [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords)
|
||||||
- [Blank and Empty Strings in Java](https://www.baeldung.com/java-blank-empty-strings)
|
- [Blank and Empty Strings in Java](https://www.baeldung.com/java-blank-empty-strings)
|
||||||
|
- [String Initialization in Java](https://www.baeldung.com/java-string-initialization)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
## Relevant articles:
|
|
||||||
|
|
||||||
- [JHipster with a Microservice Architecture](http://www.baeldung.com/jhipster-microservices)
|
|
||||||
- [Intro to JHipster](http://www.baeldung.com/jhipster)
|
|
||||||
- [Building a Basic UAA-Secured JHipster Microservice](https://www.baeldung.com/jhipster-uaa-secured-micro-service)
|
|
||||||
- [Creating New Roles and Authorities in JHipster](https://www.baeldung.com/jhipster-new-roles)
|
|
|
@ -1,3 +0,0 @@
|
||||||
### Relevant Articles:
|
|
||||||
|
|
||||||
- [Intro to Morphia](http://www.baeldung.com/intro-to-morphia)
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.baeldung.morphia</groupId>
|
|
||||||
<artifactId>morphia</artifactId>
|
|
||||||
<name>morphia</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-modules</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
<relativePath>..</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>dev.morphia.morphia</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>${morphia.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot-maven-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
|
|
||||||
<morphia.version>1.5.3</morphia.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -4,3 +4,4 @@
|
||||||
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
|
- [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps)
|
||||||
- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
|
- [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences)
|
||||||
- [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints)
|
- [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints)
|
||||||
|
- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many)
|
|
@ -58,7 +58,7 @@
|
||||||
<finalName>hibernate-mapping</finalName>
|
<finalName>hibernate-mapping</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/test/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.baeldung.hibernate.oneToMany.config;
|
package com.baeldung.hibernate.oneToMany.config;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.boot.Metadata;
|
||||||
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.Configuration;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
public class HibernateAnnotationUtil {
|
public class HibernateAnnotationUtil {
|
||||||
|
@ -12,16 +13,12 @@ public class HibernateAnnotationUtil {
|
||||||
private static SessionFactory buildSessionFactory() {
|
private static SessionFactory buildSessionFactory() {
|
||||||
try {
|
try {
|
||||||
// Create the SessionFactory from hibernate-annotation.cfg.xml
|
// Create the SessionFactory from hibernate-annotation.cfg.xml
|
||||||
Configuration configuration = new Configuration();
|
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure("hibernate-annotation.cfg.xml").build();
|
||||||
configuration.configure("hibernate-annotation.cfg.xml");
|
Metadata metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build();
|
||||||
System.out.println("Hibernate Annotation Configuration loaded");
|
SessionFactory sessionFactory = metadata.getSessionFactoryBuilder().build();
|
||||||
|
|
||||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
|
|
||||||
System.out.println("Hibernate Annotation serviceRegistry created");
|
|
||||||
|
|
||||||
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
|
|
||||||
|
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
|
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
System.err.println("Initial SessionFactory creation failed." + ex);
|
System.err.println("Initial SessionFactory creation failed." + ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
|
@ -4,11 +4,11 @@
|
||||||
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||||
<hibernate-configuration>
|
<hibernate-configuration>
|
||||||
<session-factory>
|
<session-factory>
|
||||||
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
|
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
|
||||||
<property name="hibernate.connection.password">mypassword</property>
|
<property name="hibernate.connection.password"></property>
|
||||||
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring_hibernate_one_to_many?createDatabaseIfNotExist=true</property>
|
<property name="hibernate.connection.url">jdbc:h2:mem:spring_hibernate_one_to_many</property>
|
||||||
<property name="hibernate.connection.username">myuser</property>
|
<property name="hibernate.connection.username">sa</property>
|
||||||
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
|
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
|
||||||
<property name="hbm2ddl.auto">create</property>
|
<property name="hbm2ddl.auto">create</property>
|
||||||
<property name="hibernate.current_session_context_class">thread</property>
|
<property name="hibernate.current_session_context_class">thread</property>
|
||||||
<property name="hibernate.show_sql">true</property>
|
<property name="hibernate.show_sql">true</property>
|
|
@ -10,7 +10,7 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -18,6 +18,7 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.baeldung.hibernate.oneToMany.model.Cart;
|
import com.baeldung.hibernate.oneToMany.model.Cart;
|
||||||
import com.baeldung.hibernate.oneToMany.model.Items;
|
import com.baeldung.hibernate.oneToMany.model.Items;
|
||||||
|
|
||||||
|
@ -33,9 +34,9 @@ public class HibernateOneToManyAnnotationMainIntegrationTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeTests() {
|
public static void beforeTests() {
|
||||||
Configuration configuration = new Configuration().addAnnotatedClass(Cart.class).addAnnotatedClass(Items.class)
|
Configuration configuration = new Configuration().addAnnotatedClass(Cart.class).addAnnotatedClass(Items.class)
|
||||||
.setProperty("hibernate.dialect", HSQLDialect.class.getName())
|
.setProperty("hibernate.dialect", H2Dialect.class.getName())
|
||||||
.setProperty("hibernate.connection.driver_class", org.hsqldb.jdbcDriver.class.getName())
|
.setProperty("hibernate.connection.driver_class", org.h2.Driver.class.getName())
|
||||||
.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test")
|
.setProperty("hibernate.connection.url", "jdbc:h2:mem:test")
|
||||||
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
|
.setProperty("hibernate.connection.username", "sa").setProperty("hibernate.connection.password", "")
|
||||||
.setProperty("hibernate.hbm2ddl.auto", "update");
|
.setProperty("hibernate.hbm2ddl.auto", "update");
|
||||||
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
|
|
@ -13,3 +13,4 @@
|
||||||
- [Defining JPA Entities](https://www.baeldung.com/jpa-entities)
|
- [Defining JPA Entities](https://www.baeldung.com/jpa-entities)
|
||||||
- [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation)
|
- [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation)
|
||||||
- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values)
|
- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values)
|
||||||
|
- [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa)
|
||||||
|
|
|
@ -1,40 +1,49 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project
|
||||||
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>
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
<groupId>com.baeldung</groupId>
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<artifactId>java-mongodb</artifactId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>java-mongodb</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>java-mongodb</name>
|
<name>java-mongodb</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<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>
|
<relativePath>../../</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.flapdoodle.embedmongo</groupId>
|
<groupId>de.flapdoodle.embedmongo</groupId>
|
||||||
<artifactId>de.flapdoodle.embedmongo</artifactId>
|
<artifactId>de.flapdoodle.embedmongo</artifactId>
|
||||||
<version>${flapdoodle.version}</version>
|
<version>${flapdoodle.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
<version>${mongo.version}</version>
|
<version>${mongo.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>dev.morphia.morphia</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>${morphia.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<properties>
|
</dependencies>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<properties>
|
||||||
<mongo.version>3.10.1</mongo.version>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<flapdoodle.version>1.11</flapdoodle.version>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
</properties>
|
<mongo.version>3.10.1</mongo.version>
|
||||||
|
<flapdoodle.version>1.11</flapdoodle.version>
|
||||||
|
<morphia.version>1.5.3</morphia.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.baeldung.morphia;
|
||||||
|
|
||||||
import static dev.morphia.aggregation.Group.grouping;
|
import static dev.morphia.aggregation.Group.grouping;
|
||||||
import static dev.morphia.aggregation.Group.push;
|
import static dev.morphia.aggregation.Group.push;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
@ -51,8 +52,8 @@ public class MorphiaIntegrationTest {
|
||||||
.contains("Learning Java")
|
.contains("Learning Java")
|
||||||
.find()
|
.find()
|
||||||
.toList();
|
.toList();
|
||||||
assertEquals(books.size(), 1);
|
assertEquals(1, books.size());
|
||||||
assertEquals(books.get(0), book);
|
assertEquals(book, books.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -71,8 +72,8 @@ public class MorphiaIntegrationTest {
|
||||||
.contains("Learning Java")
|
.contains("Learning Java")
|
||||||
.find()
|
.find()
|
||||||
.toList();
|
.toList();
|
||||||
assertEquals(books.get(0)
|
assertEquals(4.95, books.get(0)
|
||||||
.getCost(), 4.95);
|
.getCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -89,7 +90,7 @@ public class MorphiaIntegrationTest {
|
||||||
.contains("Learning Java")
|
.contains("Learning Java")
|
||||||
.find()
|
.find()
|
||||||
.toList();
|
.toList();
|
||||||
assertEquals(books.size(), 0);
|
assertEquals(0, books.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -123,7 +124,7 @@ public class MorphiaIntegrationTest {
|
||||||
assertEquals(books.size(), 1);
|
assertEquals(books.size(), 1);
|
||||||
assertEquals("Learning Java", books.get(0)
|
assertEquals("Learning Java", books.get(0)
|
||||||
.getTitle());
|
.getTitle());
|
||||||
assertEquals(null, books.get(0)
|
assertNull(books.get(0)
|
||||||
.getAuthor());
|
.getAuthor());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Overview of JPA/Hibernate Cascade Types](https://www.baeldung.com/jpa-cascade-types)
|
|
@ -12,3 +12,4 @@
|
||||||
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
|
||||||
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
|
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
|
||||||
- [Derived Query Methods in Spring Data JPA Repositories](https://www.baeldung.com/spring-data-derived-queries)
|
- [Derived Query Methods in Spring Data JPA Repositories](https://www.baeldung.com/spring-data-derived-queries)
|
||||||
|
- [LIKE Queries in Spring JPA Repositories](https://www.baeldung.com/spring-jpa-like-queries)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
- [Stored Procedures with Hibernate](http://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
|
- [Stored Procedures with Hibernate](http://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
|
||||||
- [Hibernate: save, persist, update, merge, saveOrUpdate](http://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
|
- [Hibernate: save, persist, update, merge, saveOrUpdate](http://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
|
||||||
- [Eager/Lazy Loading In Hibernate](http://www.baeldung.com/hibernate-lazy-eager-loading)
|
- [Eager/Lazy Loading In Hibernate](http://www.baeldung.com/hibernate-lazy-eager-loading)
|
||||||
- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many)
|
|
||||||
- [The DAO with Spring and Hibernate](http://www.baeldung.com/persistence-layer-with-spring-and-hibernate)
|
- [The DAO with Spring and Hibernate](http://www.baeldung.com/persistence-layer-with-spring-and-hibernate)
|
||||||
|
|
||||||
### Quick Start
|
### Quick Start
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class PersistenceJPAConfig {
|
||||||
// beans
|
// beans
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||||
em.setDataSource(dataSource());
|
em.setDataSource(dataSource());
|
||||||
em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
||||||
|
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
|
||||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -27,6 +28,8 @@ public class EmployeeDAO {
|
||||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
private SimpleJdbcInsert simpleJdbcInsert;
|
private SimpleJdbcInsert simpleJdbcInsert;
|
||||||
|
|
||||||
|
private SimpleJdbcCall simpleJdbcCall;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setDataSource(final DataSource dataSource) {
|
public void setDataSource(final DataSource dataSource) {
|
||||||
|
@ -36,7 +39,9 @@ public class EmployeeDAO {
|
||||||
|
|
||||||
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||||
simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE");
|
simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE");
|
||||||
|
|
||||||
|
// Commented as the database is H2, change the database and create procedure READ_EMPLOYEE before calling getEmployeeUsingSimpleJdbcCall
|
||||||
|
//simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("READ_EMPLOYEE");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCountOfEmployees() {
|
public int getCountOfEmployees() {
|
||||||
|
@ -110,4 +115,15 @@ public class EmployeeDAO {
|
||||||
final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch);
|
final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch);
|
||||||
return updateCounts;
|
return updateCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Employee getEmployeeUsingSimpleJdbcCall(int id) {
|
||||||
|
SqlParameterSource in = new MapSqlParameterSource().addValue("in_id", id);
|
||||||
|
Map<String, Object> out = simpleJdbcCall.execute(in);
|
||||||
|
|
||||||
|
Employee emp = new Employee();
|
||||||
|
emp.setFirstName((String) out.get("FIRST_NAME"));
|
||||||
|
emp.setLastName((String) out.get("LAST_NAME"));
|
||||||
|
|
||||||
|
return emp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
17
pom.xml
17
pom.xml
|
@ -480,7 +480,6 @@
|
||||||
<module>jersey</module>
|
<module>jersey</module>
|
||||||
<module>JGit</module>
|
<module>JGit</module>
|
||||||
<module>jgroups</module>
|
<module>jgroups</module>
|
||||||
<module>jhipster</module>
|
|
||||||
<module>jhipster-5</module>
|
<module>jhipster-5</module>
|
||||||
<module>jib</module>
|
<module>jib</module>
|
||||||
<module>jjwt</module>
|
<module>jjwt</module>
|
||||||
|
@ -545,7 +544,6 @@
|
||||||
<!-- <module>raml</module> --> <!-- Not a maven project -->
|
<!-- <module>raml</module> --> <!-- Not a maven project -->
|
||||||
<module>ratpack</module>
|
<module>ratpack</module>
|
||||||
<module>reactor-core</module>
|
<module>reactor-core</module>
|
||||||
<module>rest-with-spark-java</module>
|
|
||||||
<module>resteasy</module>
|
<module>resteasy</module>
|
||||||
<module>restx</module>
|
<module>restx</module>
|
||||||
<!-- <module>rmi</module> --> <!-- Not a maven project -->
|
<!-- <module>rmi</module> --> <!-- Not a maven project -->
|
||||||
|
@ -757,8 +755,6 @@
|
||||||
|
|
||||||
<module>spring-thymeleaf</module>
|
<module>spring-thymeleaf</module>
|
||||||
|
|
||||||
<module>spring-userservice</module>
|
|
||||||
|
|
||||||
<module>spring-vault</module>
|
<module>spring-vault</module>
|
||||||
<module>spring-vertx</module>
|
<module>spring-vertx</module>
|
||||||
|
|
||||||
|
@ -778,7 +774,6 @@
|
||||||
|
|
||||||
<module>undertow</module>
|
<module>undertow</module>
|
||||||
|
|
||||||
<module>vavr</module>
|
|
||||||
<module>vertx</module>
|
<module>vertx</module>
|
||||||
<module>vertx-and-rxjava</module>
|
<module>vertx-and-rxjava</module>
|
||||||
<module>video-tutorials</module>
|
<module>video-tutorials</module>
|
||||||
|
@ -787,13 +782,11 @@
|
||||||
<module>wicket</module>
|
<module>wicket</module>
|
||||||
|
|
||||||
<module>xml</module>
|
<module>xml</module>
|
||||||
<module>xmlunit-2</module>
|
|
||||||
<module>xstream</module>
|
<module>xstream</module>
|
||||||
|
|
||||||
<module>tensorflow-java</module>
|
<module>tensorflow-java</module>
|
||||||
<module>spring-boot-flowable</module>
|
<module>spring-boot-flowable</module>
|
||||||
<module>spring-security-kerberos</module>
|
<module>spring-security-kerberos</module>
|
||||||
<module>morphia</module>
|
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
@ -929,7 +922,6 @@
|
||||||
<module>spring-state-machine</module>
|
<module>spring-state-machine</module>
|
||||||
<module>spring-swagger-codegen/spring-swagger-codegen-app</module>
|
<module>spring-swagger-codegen/spring-swagger-codegen-app</module>
|
||||||
<module>spring-thymeleaf</module>
|
<module>spring-thymeleaf</module>
|
||||||
<module>spring-userservice</module>
|
|
||||||
<module>spring-vault</module>
|
<module>spring-vault</module>
|
||||||
<module>spring-vertx</module>
|
<module>spring-vertx</module>
|
||||||
<module>spring-zuul/spring-zuul-foos-resource</module>
|
<module>spring-zuul/spring-zuul-foos-resource</module>
|
||||||
|
@ -985,6 +977,7 @@
|
||||||
<module>core-kotlin-io</module>
|
<module>core-kotlin-io</module>
|
||||||
|
|
||||||
<module>jenkins/hello-world</module>
|
<module>jenkins/hello-world</module>
|
||||||
|
<module>jhipster</module>
|
||||||
<module>jws</module>
|
<module>jws</module>
|
||||||
|
|
||||||
<module>libraries</module> <!-- very long running -->
|
<module>libraries</module> <!-- very long running -->
|
||||||
|
@ -995,6 +988,7 @@
|
||||||
<module>persistence-modules/jnosql</module>
|
<module>persistence-modules/jnosql</module>
|
||||||
|
|
||||||
<module>vaadin</module>
|
<module>vaadin</module>
|
||||||
|
<module>vavr</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
@ -1166,7 +1160,6 @@
|
||||||
<module>jersey</module>
|
<module>jersey</module>
|
||||||
<module>JGit</module>
|
<module>JGit</module>
|
||||||
<module>jgroups</module>
|
<module>jgroups</module>
|
||||||
<module>jhipster</module>
|
|
||||||
<module>jhipster-5</module>
|
<module>jhipster-5</module>
|
||||||
<module>jib</module>
|
<module>jib</module>
|
||||||
<module>jjwt</module>
|
<module>jjwt</module>
|
||||||
|
@ -1228,7 +1221,6 @@
|
||||||
<!-- <module>raml</module> --> <!-- Not a maven project -->
|
<!-- <module>raml</module> --> <!-- Not a maven project -->
|
||||||
<module>ratpack</module>
|
<module>ratpack</module>
|
||||||
<module>reactor-core</module>
|
<module>reactor-core</module>
|
||||||
<module>rest-with-spark-java</module>
|
|
||||||
<module>resteasy</module>
|
<module>resteasy</module>
|
||||||
<module>restx</module>
|
<module>restx</module>
|
||||||
<!-- <module>rmi</module> --> <!-- Not a maven project -->
|
<!-- <module>rmi</module> --> <!-- Not a maven project -->
|
||||||
|
@ -1425,8 +1417,6 @@
|
||||||
|
|
||||||
<module>spring-thymeleaf</module>
|
<module>spring-thymeleaf</module>
|
||||||
|
|
||||||
<module>spring-userservice</module>
|
|
||||||
|
|
||||||
<module>spring-vault</module>
|
<module>spring-vault</module>
|
||||||
<module>spring-vertx</module>
|
<module>spring-vertx</module>
|
||||||
|
|
||||||
|
@ -1446,7 +1436,6 @@
|
||||||
|
|
||||||
<module>undertow</module>
|
<module>undertow</module>
|
||||||
|
|
||||||
<module>vavr</module>
|
|
||||||
<module>vertx</module>
|
<module>vertx</module>
|
||||||
<module>vertx-and-rxjava</module>
|
<module>vertx-and-rxjava</module>
|
||||||
<module>video-tutorials</module>
|
<module>video-tutorials</module>
|
||||||
|
@ -1498,6 +1487,7 @@
|
||||||
<module>core-kotlin-2</module>
|
<module>core-kotlin-2</module>
|
||||||
|
|
||||||
<module>jenkins/hello-world</module>
|
<module>jenkins/hello-world</module>
|
||||||
|
<module>jhipster</module>
|
||||||
<module>jws</module>
|
<module>jws</module>
|
||||||
|
|
||||||
<module>libraries</module> <!-- very long running -->
|
<module>libraries</module> <!-- very long running -->
|
||||||
|
@ -1508,6 +1498,7 @@
|
||||||
<module>persistence-modules/jnosql</module>
|
<module>persistence-modules/jnosql</module>
|
||||||
|
|
||||||
<module>vaadin</module>
|
<module>vaadin</module>
|
||||||
|
<module>vavr</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
</profile>
|
</profile>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
## Relevant articles:
|
## Relevant articles:
|
||||||
|
|
||||||
- [Guide to QuarkusIO](hhttps://www.baeldung.com/quarkus-io)
|
- [Guide to QuarkusIO](https://www.baeldung.com/quarkus-io)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
## Relevant articles:
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>rest-with-spark-java</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>rest-with-spark-java</name>
|
|
||||||
<url>http://maven.apache.org</url>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-modules</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sparkjava</groupId>
|
|
||||||
<artifactId>spark-core</artifactId>
|
|
||||||
<version>${spark-core.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<spark-core.version>2.5.4</spark-core.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,50 +0,0 @@
|
||||||
package com.baeldung;
|
|
||||||
|
|
||||||
import static spark.Spark.after;
|
|
||||||
import static spark.Spark.before;
|
|
||||||
import static spark.Spark.delete;
|
|
||||||
import static spark.Spark.get;
|
|
||||||
import static spark.Spark.post;
|
|
||||||
import static spark.Spark.port;
|
|
||||||
|
|
||||||
import com.baeldung.domain.Book;
|
|
||||||
import com.baeldung.service.LibraryService;
|
|
||||||
|
|
||||||
public class Router {
|
|
||||||
|
|
||||||
public static void main( String[] args ){
|
|
||||||
|
|
||||||
port(8080);
|
|
||||||
|
|
||||||
before((request, response) -> {
|
|
||||||
|
|
||||||
//do some filtering stuff
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
after((request, response) -> {
|
|
||||||
response.type("application/json");
|
|
||||||
});
|
|
||||||
|
|
||||||
get("ListOfBooks", (request, response) -> {
|
|
||||||
return LibraryService.view();
|
|
||||||
});
|
|
||||||
|
|
||||||
get("SearchBook/:title", (request, response) -> {
|
|
||||||
return LibraryService.view(request.params("title"));
|
|
||||||
});
|
|
||||||
|
|
||||||
post("AddBook/:title/:author/:publisher", (request, response) -> {
|
|
||||||
Book book = new Book();
|
|
||||||
book.setTitle(request.params("title"));
|
|
||||||
book.setAuthor(request.params("author"));
|
|
||||||
book.setPublisher(request.params("publisher"));
|
|
||||||
return LibraryService.add(book);
|
|
||||||
});
|
|
||||||
|
|
||||||
delete("DeleteBook/:title", (request, response) -> {
|
|
||||||
return LibraryService.delete(request.params("title"));
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package com.baeldung.domain;
|
|
||||||
|
|
||||||
public class Book {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
private String author;
|
|
||||||
private String publisher;
|
|
||||||
|
|
||||||
public Book() {}
|
|
||||||
|
|
||||||
public Book(String title, String author, String publisher) {
|
|
||||||
super();
|
|
||||||
this.title = title;
|
|
||||||
this.author = author;
|
|
||||||
this.publisher = publisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
public String getAuthor() {
|
|
||||||
return author;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthor(String author) {
|
|
||||||
this.author = author;
|
|
||||||
}
|
|
||||||
public String getPublisher() {
|
|
||||||
return publisher;
|
|
||||||
}
|
|
||||||
public void setPublisher(String publisher) {
|
|
||||||
this.publisher = publisher;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(Object other) {
|
|
||||||
return other instanceof Book;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == this) return true;
|
|
||||||
if (!(o instanceof Book)) return false;
|
|
||||||
Book other = (Book) o;
|
|
||||||
if (!other.canEqual((Object)this)) return false;
|
|
||||||
if (this.getTitle() == null ? other.getTitle() != null : !this.getTitle().equals(other.getTitle())) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.baeldung.service;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.baeldung.domain.Book;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
|
||||||
|
|
||||||
public class LibraryService {
|
|
||||||
|
|
||||||
private static ObjectWriter mapper = new ObjectMapper().writer().withDefaultPrettyPrinter();
|
|
||||||
private static Map<String, Book> library = new HashMap<String,Book>();
|
|
||||||
|
|
||||||
public static String view() throws JsonProcessingException {
|
|
||||||
List<Book> books = new ArrayList<Book>();
|
|
||||||
library.forEach((key, value) -> {
|
|
||||||
books.add(value);
|
|
||||||
});
|
|
||||||
return mapper.writeValueAsString(books);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String view(String title) throws JsonProcessingException {
|
|
||||||
return mapper.writeValueAsString(library.get(title));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String add(Book book) throws JsonProcessingException {
|
|
||||||
library.put(book.getTitle(), book);
|
|
||||||
return mapper.writeValueAsString(book);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String delete(String title) throws JsonProcessingException {
|
|
||||||
Book deletedBook = library.remove(title);
|
|
||||||
return mapper.writeValueAsString(deletedBook);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?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>
|
|
|
@ -1,148 +0,0 @@
|
||||||
package com.baeldung;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.baeldung.domain.Book;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
public class AppLiveTest extends TestCase {
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
|
|
||||||
public AppLiveTest( String testName ) {
|
|
||||||
super( testName );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
return new TestSuite( AppLiveTest.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testApp() throws IOException, ClassNotFoundException {
|
|
||||||
|
|
||||||
URL url;
|
|
||||||
HttpURLConnection conn;
|
|
||||||
BufferedReader br;
|
|
||||||
String output;
|
|
||||||
StringBuffer resp;
|
|
||||||
Book book;
|
|
||||||
Book temp;
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/AddBook/Odessy/YannMartel/GreenLeaves");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("POST");
|
|
||||||
conn.getContent();
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
book = mapper.readValue(resp.toString(), Book.class);
|
|
||||||
temp = new Book("Odessy","YannMartel","GreenLeaves");
|
|
||||||
|
|
||||||
assertEquals(book, temp);
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/AddBook/Twilight/StephenieMeyer/LittleBrown");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("POST");
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
book = mapper.readValue(resp.toString(), Book.class);
|
|
||||||
temp = new Book("Twilight","StephenieMeyer","LittleBrown");
|
|
||||||
|
|
||||||
assertEquals(book, temp);
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/ListOfBooks");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Book> books = new ArrayList<Book>();
|
|
||||||
|
|
||||||
books.add(new Book("Odessy","YannMartel","GreenLeaves"));
|
|
||||||
books.add(new Book("Twilight","StephenieMeyer","LittleBrown"));
|
|
||||||
|
|
||||||
List<Book> listOfBooks = mapper.readValue(resp.toString(), new TypeReference<List<Book>>(){});
|
|
||||||
|
|
||||||
assertEquals(books, listOfBooks);
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/SearchBook/Twilight");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
book = mapper.readValue(resp.toString(), Book.class);
|
|
||||||
temp = new Book("Twilight","StephenieMeyer","LittleBrown");
|
|
||||||
|
|
||||||
assertEquals(book, temp);
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/DeleteBook/Twilight");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("DELETE");
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
book = mapper.readValue(resp.toString(), Book.class);
|
|
||||||
temp = new Book("Twilight","StephenieMeyer","LittleBrown");
|
|
||||||
|
|
||||||
assertEquals(book, temp);
|
|
||||||
|
|
||||||
url = new URL("http://localhost:8080/ListOfBooks");
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
br = new BufferedReader(new InputStreamReader(
|
|
||||||
(conn.getInputStream())));
|
|
||||||
resp = new StringBuffer();
|
|
||||||
|
|
||||||
while ((output = br.readLine()) != null) {
|
|
||||||
resp.append(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
books = new ArrayList<Book>();
|
|
||||||
|
|
||||||
books.add(new Book("Odessy","YannMartel","GreenLeaves"));
|
|
||||||
listOfBooks = mapper.readValue(resp.toString(), new TypeReference<List<Book>>(){});
|
|
||||||
|
|
||||||
assertEquals(books, listOfBooks);
|
|
||||||
|
|
||||||
conn.disconnect();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [Introduction to SPF4J](https://www.baeldung.com/spf4j)
|
|
@ -77,29 +77,34 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-tx</artifactId>
|
<artifactId>spring-tx</artifactId>
|
||||||
<version>5.2.0.M2</version>
|
<version>${spring-tx.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-r2dbc</artifactId>
|
<artifactId>spring-data-r2dbc</artifactId>
|
||||||
<version>1.0.0.M2</version>
|
<version>${spring-data-r2dbc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.r2dbc</groupId>
|
<groupId>io.r2dbc</groupId>
|
||||||
<artifactId>r2dbc-h2</artifactId>
|
<artifactId>r2dbc-h2</artifactId>
|
||||||
<version>0.8.0.M8</version>
|
<version>${r2dbc-h2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.199</version>
|
<version>${h2.version}</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>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>${httpclient.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -195,11 +200,6 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<kotlin.version>1.2.40</kotlin.version>
|
|
||||||
<kotlin-maven-plugin.version>1.2.40</kotlin-maven-plugin.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-snapshots</id>
|
<id>spring-snapshots</id>
|
||||||
|
@ -216,5 +216,15 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<kotlin.version>1.2.40</kotlin.version>
|
||||||
|
<kotlin-maven-plugin.version>1.2.40</kotlin-maven-plugin.version>
|
||||||
|
<spring-tx.version>5.2.0.M2</spring-tx.version>
|
||||||
|
<spring-data-r2dbc.version>1.0.0.M2</spring-data-r2dbc.version>
|
||||||
|
<r2dbc-h2.version>0.8.0.M8</r2dbc-h2.version>
|
||||||
|
<httpclient.version>4.5.2</httpclient.version>
|
||||||
|
<h2.version>1.4.199</h2.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DownstreamServiceReactiveHealthIndicator implements ReactiveHealthIndicator {
|
public class DownstreamServiceHealthIndicator implements ReactiveHealthIndicator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Health> health() {
|
public Mono<Health> health() {
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.baeldung.startup;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ProfileManager {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
public void getActiveProfiles() {
|
||||||
|
for (final String profileName : environment.getActiveProfiles()) {
|
||||||
|
System.out.println("Currently active profile - " + profileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,3 +12,5 @@
|
||||||
- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api)
|
- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api)
|
||||||
- [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally)
|
- [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally)
|
||||||
- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
|
- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
|
||||||
|
- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity)
|
||||||
|
- [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations)
|
||||||
|
|
|
@ -36,5 +36,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||||
- [Injecting Git Information Into Spring](https://www.baeldung.com/spring-git-information)
|
- [Injecting Git Information Into Spring](https://www.baeldung.com/spring-git-information)
|
||||||
- [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation)
|
- [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation)
|
||||||
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
|
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
|
||||||
- [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application)
|
|
||||||
- [Guide to @EnableConfigurationProperties](https://www.baeldung.com/spring-enable-config-properties)
|
- [Guide to @EnableConfigurationProperties](https://www.baeldung.com/spring-enable-config-properties)
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml)
|
- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml)
|
||||||
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
|
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
|
||||||
- [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults)
|
- [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults)
|
||||||
- [Groovy Bean Definitions](http://www.baeldung.com/spring-groovy-beans)
|
|
||||||
- [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection)
|
- [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection)
|
||||||
- [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation)
|
- [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation)
|
||||||
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
|
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
|
||||||
|
@ -24,3 +23,4 @@
|
||||||
- [What is a Spring Bean?](https://www.baeldung.com/spring-bean)
|
- [What is a Spring Bean?](https://www.baeldung.com/spring-bean)
|
||||||
- [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy)
|
- [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy)
|
||||||
- [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection)
|
- [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection)
|
||||||
|
- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
|
||||||
|
|
|
@ -8,11 +8,11 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial)
|
- [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial)
|
||||||
- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
|
- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
|
||||||
- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity)
|
|
||||||
- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
|
- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
|
||||||
- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings)
|
- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings)
|
||||||
- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml)
|
- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml)
|
||||||
- [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts)
|
- [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts)
|
||||||
- [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator)
|
- [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator)
|
||||||
- [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status)
|
- [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status)
|
||||||
- [Spring MVC and the @ModelAttribute Annotation](http://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation)
|
- [Spring MVC and the @ModelAttribute Annotation](http://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation)
|
||||||
|
- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable)
|
|
@ -1,16 +1,18 @@
|
||||||
package com.baeldung.exception;
|
package com.baeldung.exception;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ControllerAdvice
|
||||||
public class HttpMediaTypeNotAcceptableExceptionExampleController {
|
public class HttpMediaTypeNotAcceptableExceptionExampleController {
|
||||||
|
|
||||||
@PostMapping(value = "/test", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@PostMapping(value = "/test", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.baeldung.exception;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
import com.baeldung.Application;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = Application.class)
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
public class HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MockMvc mockMvc;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenHttpMediaTypeNotAcceptableExceptionTriggered_thenExceptionHandled() throws Exception {
|
||||||
|
mockMvc.perform(post("/test").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_PDF))
|
||||||
|
.andExpect(content().string("acceptable MIME type:application/json"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,18 +6,15 @@
|
||||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations)
|
|
||||||
- [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial)
|
- [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial)
|
||||||
- [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial)
|
- [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial)
|
||||||
- [Integration Testing in Spring](http://www.baeldung.com/integration-testing-in-spring)
|
- [Integration Testing in Spring](http://www.baeldung.com/integration-testing-in-spring)
|
||||||
- [A Quick Guide to Spring MVC Matrix Variables](http://www.baeldung.com/spring-mvc-matrix-variables)
|
- [A Quick Guide to Spring MVC Matrix Variables](http://www.baeldung.com/spring-mvc-matrix-variables)
|
||||||
- [Intro to WebSockets with Spring](http://www.baeldung.com/websockets-spring)
|
- [Intro to WebSockets with Spring](http://www.baeldung.com/websockets-spring)
|
||||||
- [File Upload with Spring MVC](http://www.baeldung.com/spring-file-upload)
|
- [File Upload with Spring MVC](http://www.baeldung.com/spring-file-upload)
|
||||||
- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
|
|
||||||
- [Introduction to HtmlUnit](http://www.baeldung.com/htmlunit)
|
- [Introduction to HtmlUnit](http://www.baeldung.com/htmlunit)
|
||||||
- [Upload and Display Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files)
|
- [Upload and Display Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files)
|
||||||
- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config)
|
- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config)
|
||||||
- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable)
|
|
||||||
- [Spring MVC @PathVariable with a dot (.) gets truncated](http://www.baeldung.com/spring-mvc-pathvariable-dot)
|
- [Spring MVC @PathVariable with a dot (.) gets truncated](http://www.baeldung.com/spring-mvc-pathvariable-dot)
|
||||||
- [A Quick Example of Spring Websockets’ @SendToUser Annotation](http://www.baeldung.com/spring-websockets-sendtouser)
|
- [A Quick Example of Spring Websockets’ @SendToUser Annotation](http://www.baeldung.com/spring-websockets-sendtouser)
|
||||||
- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters)
|
- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.config;
|
package com.baeldung;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
@ -7,8 +7,8 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan("org.baeldung")
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ComponentScan("com.baeldung.cors")
|
||||||
public class Application extends SpringBootServletInitializer {
|
public class Application extends SpringBootServletInitializer {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
|
@ -1,6 +1,5 @@
|
||||||
package org.baeldung.config;
|
package com.baeldung.config;
|
||||||
|
|
||||||
import org.baeldung.config.converter.KryoHttpMessageConverter;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -13,9 +12,12 @@ import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConve
|
||||||
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
|
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
|
||||||
import org.springframework.oxm.xstream.XStreamMarshaller;
|
import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||||
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import com.baeldung.config.converter.KryoHttpMessageConverter;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -24,10 +26,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan({ "org.baeldung.web" })
|
@ComponentScan({ "com.baeldung.web" })
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
public class MvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
public WebConfig() {
|
public MvcConfig() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,4 +66,10 @@ public class WebConfig implements WebMvcConfigurer {
|
||||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||||
configurer.defaultContentType(MediaType.APPLICATION_JSON);
|
configurer.defaultContentType(MediaType.APPLICATION_JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/**");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package org.baeldung.config.converter;
|
package com.baeldung.config.converter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.baeldung.web.dto.Foo;
|
|
||||||
import org.springframework.http.HttpInputMessage;
|
import org.springframework.http.HttpInputMessage;
|
||||||
import org.springframework.http.HttpOutputMessage;
|
import org.springframework.http.HttpOutputMessage;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.AbstractHttpMessageConverter;
|
import org.springframework.http.converter.AbstractHttpMessageConverter;
|
||||||
|
|
||||||
|
import com.baeldung.web.dto.Foo;
|
||||||
import com.esotericsoftware.kryo.Kryo;
|
import com.esotericsoftware.kryo.Kryo;
|
||||||
import com.esotericsoftware.kryo.io.Input;
|
import com.esotericsoftware.kryo.io.Input;
|
||||||
import com.esotericsoftware.kryo.io.Output;
|
import com.esotericsoftware.kryo.io.Output;
|
|
@ -6,4 +6,13 @@ public class Account {
|
||||||
public Account(Long id) {
|
public Account(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.baeldung.cors;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebMvc
|
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
|
||||||
registry.addMapping("/**");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.controller;
|
package com.baeldung.web.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@ -1,9 +1,8 @@
|
||||||
package org.baeldung.web.controller;
|
package com.baeldung.web.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.web.dto.Bazz;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
@ -15,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.baeldung.web.dto.Bazz;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
|
@ -1,11 +1,9 @@
|
||||||
package org.baeldung.web.controller;
|
package com.baeldung.web.controller;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.baeldung.web.dto.Foo;
|
|
||||||
import org.baeldung.web.dto.FooProtos;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
@ -16,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
import com.baeldung.web.dto.Foo;
|
||||||
|
import com.baeldung.web.dto.FooProtos;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.controller;
|
package com.baeldung.web.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.controller.status;
|
package com.baeldung.web.controller.status;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.controller.status;
|
package com.baeldung.web.controller.status;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.dto;
|
package com.baeldung.web.dto;
|
||||||
|
|
||||||
public class Bazz {
|
public class Bazz {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.dto;
|
package com.baeldung.web.dto;
|
||||||
|
|
||||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: FooProtos.proto
|
// source: FooProtos.proto
|
||||||
|
|
||||||
package org.baeldung.web.dto;
|
package com.baeldung.web.dto;
|
||||||
|
|
||||||
public final class FooProtos {
|
public final class FooProtos {
|
||||||
private FooProtos() {
|
private FooProtos() {
|
||||||
|
@ -115,11 +115,11 @@ public final class FooProtos {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
||||||
return org.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
|
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
|
||||||
return org.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(org.baeldung.web.dto.FooProtos.Foo.class, org.baeldung.web.dto.FooProtos.Foo.Builder.class);
|
return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.web.dto.FooProtos.Foo.class, com.baeldung.web.dto.FooProtos.Foo.Builder.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static com.google.protobuf.Parser<Foo> PARSER = new com.google.protobuf.AbstractParser<Foo>() {
|
public static com.google.protobuf.Parser<Foo> PARSER = new com.google.protobuf.AbstractParser<Foo>() {
|
||||||
|
@ -255,43 +255,43 @@ public final class FooProtos {
|
||||||
return super.writeReplace();
|
return super.writeReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException {
|
||||||
return PARSER.parseFrom(data);
|
return PARSER.parseFrom(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
|
||||||
return PARSER.parseFrom(data, extensionRegistry);
|
return PARSER.parseFrom(data, extensionRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException {
|
||||||
return PARSER.parseFrom(data);
|
return PARSER.parseFrom(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException {
|
||||||
return PARSER.parseFrom(data, extensionRegistry);
|
return PARSER.parseFrom(data, extensionRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(java.io.InputStream input) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(java.io.InputStream input) throws java.io.IOException {
|
||||||
return PARSER.parseFrom(input);
|
return PARSER.parseFrom(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
||||||
return PARSER.parseFrom(input, extensionRegistry);
|
return PARSER.parseFrom(input, extensionRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException {
|
||||||
return PARSER.parseDelimitedFrom(input);
|
return PARSER.parseDelimitedFrom(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
||||||
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
return PARSER.parseDelimitedFrom(input, extensionRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException {
|
||||||
return PARSER.parseFrom(input);
|
return PARSER.parseFrom(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
public static com.baeldung.web.dto.FooProtos.Foo parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
||||||
return PARSER.parseFrom(input, extensionRegistry);
|
return PARSER.parseFrom(input, extensionRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ public final class FooProtos {
|
||||||
return newBuilder();
|
return newBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder newBuilder(org.baeldung.web.dto.FooProtos.Foo prototype) {
|
public static Builder newBuilder(com.baeldung.web.dto.FooProtos.Foo prototype) {
|
||||||
return newBuilder().mergeFrom(prototype);
|
return newBuilder().mergeFrom(prototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,13 +322,13 @@ public final class FooProtos {
|
||||||
*/
|
*/
|
||||||
public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> implements
|
public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder> implements
|
||||||
// @@protoc_insertion_point(builder_implements:baeldung.Foo)
|
// @@protoc_insertion_point(builder_implements:baeldung.Foo)
|
||||||
org.baeldung.web.dto.FooProtos.FooOrBuilder {
|
com.baeldung.web.dto.FooProtos.FooOrBuilder {
|
||||||
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
||||||
return org.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
|
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() {
|
||||||
return org.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(org.baeldung.web.dto.FooProtos.Foo.class, org.baeldung.web.dto.FooProtos.Foo.Builder.class);
|
return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.web.dto.FooProtos.Foo.class, com.baeldung.web.dto.FooProtos.Foo.Builder.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct using org.baeldung.web.dto.FooProtos.Foo.newBuilder()
|
// Construct using org.baeldung.web.dto.FooProtos.Foo.newBuilder()
|
||||||
|
@ -364,23 +364,23 @@ public final class FooProtos {
|
||||||
}
|
}
|
||||||
|
|
||||||
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
|
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
|
||||||
return org.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public org.baeldung.web.dto.FooProtos.Foo getDefaultInstanceForType() {
|
public com.baeldung.web.dto.FooProtos.Foo getDefaultInstanceForType() {
|
||||||
return org.baeldung.web.dto.FooProtos.Foo.getDefaultInstance();
|
return com.baeldung.web.dto.FooProtos.Foo.getDefaultInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public org.baeldung.web.dto.FooProtos.Foo build() {
|
public com.baeldung.web.dto.FooProtos.Foo build() {
|
||||||
org.baeldung.web.dto.FooProtos.Foo result = buildPartial();
|
com.baeldung.web.dto.FooProtos.Foo result = buildPartial();
|
||||||
if (!result.isInitialized()) {
|
if (!result.isInitialized()) {
|
||||||
throw newUninitializedMessageException(result);
|
throw newUninitializedMessageException(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public org.baeldung.web.dto.FooProtos.Foo buildPartial() {
|
public com.baeldung.web.dto.FooProtos.Foo buildPartial() {
|
||||||
org.baeldung.web.dto.FooProtos.Foo result = new org.baeldung.web.dto.FooProtos.Foo(this);
|
com.baeldung.web.dto.FooProtos.Foo result = new com.baeldung.web.dto.FooProtos.Foo(this);
|
||||||
int from_bitField0_ = bitField0_;
|
int from_bitField0_ = bitField0_;
|
||||||
int to_bitField0_ = 0;
|
int to_bitField0_ = 0;
|
||||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
|
||||||
|
@ -397,16 +397,16 @@ public final class FooProtos {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||||
if (other instanceof org.baeldung.web.dto.FooProtos.Foo) {
|
if (other instanceof com.baeldung.web.dto.FooProtos.Foo) {
|
||||||
return mergeFrom((org.baeldung.web.dto.FooProtos.Foo) other);
|
return mergeFrom((com.baeldung.web.dto.FooProtos.Foo) other);
|
||||||
} else {
|
} else {
|
||||||
super.mergeFrom(other);
|
super.mergeFrom(other);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder mergeFrom(org.baeldung.web.dto.FooProtos.Foo other) {
|
public Builder mergeFrom(com.baeldung.web.dto.FooProtos.Foo other) {
|
||||||
if (other == org.baeldung.web.dto.FooProtos.Foo.getDefaultInstance())
|
if (other == com.baeldung.web.dto.FooProtos.Foo.getDefaultInstance())
|
||||||
return this;
|
return this;
|
||||||
if (other.hasId()) {
|
if (other.hasId()) {
|
||||||
setId(other.getId());
|
setId(other.getId());
|
||||||
|
@ -433,11 +433,11 @@ public final class FooProtos {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException {
|
||||||
org.baeldung.web.dto.FooProtos.Foo parsedMessage = null;
|
com.baeldung.web.dto.FooProtos.Foo parsedMessage = null;
|
||||||
try {
|
try {
|
||||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||||
parsedMessage = (org.baeldung.web.dto.FooProtos.Foo) e.getUnfinishedMessage();
|
parsedMessage = (com.baeldung.web.dto.FooProtos.Foo) e.getUnfinishedMessage();
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
if (parsedMessage != null) {
|
if (parsedMessage != null) {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.util;
|
package com.baeldung.web.util;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/mvc
|
http://www.springframework.org/schema/mvc
|
||||||
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||||
|
|
||||||
<mvc:cors>
|
<mvc:cors>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
import org.baeldung.config.Application;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@ -1,11 +1,11 @@
|
||||||
package org.baeldung.web.controller.mediatypes;
|
package com.baeldung.web.controller.mediatypes;
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan({ "org.baeldung.web" })
|
@ComponentScan({ "com.baeldung.web" })
|
||||||
public class TestConfig {
|
public class TestConfig {
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package org.baeldung.web.controller.status;
|
package com.baeldung.web.controller.status;
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.baeldung.config.WebConfig;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -16,8 +14,10 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
|
import com.baeldung.config.MvcConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = MvcConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@AutoConfigureWebClient
|
@AutoConfigureWebClient
|
||||||
public class ExampleControllerIntegrationTest {
|
public class ExampleControllerIntegrationTest {
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
package org.baeldung.web.test;
|
package com.baeldung.web.test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
@ -9,8 +9,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.baeldung.config.WebConfig;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -23,9 +21,11 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
|
import com.baeldung.config.MvcConfig;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = MvcConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@AutoConfigureWebClient
|
@AutoConfigureWebClient
|
||||||
public class BazzNewMappingsExampleIntegrationTest {
|
public class BazzNewMappingsExampleIntegrationTest {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.test;
|
package com.baeldung.web.test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.test;
|
package com.baeldung.web.test;
|
||||||
|
|
||||||
import static org.apache.commons.codec.binary.Base64.encodeBase64;
|
import static org.apache.commons.codec.binary.Base64.encodeBase64;
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
@ -13,7 +13,6 @@ import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.baeldung.web.dto.Foo;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
@ -31,6 +30,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RequestCallback;
|
import org.springframework.web.client.RequestCallback;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.baeldung.web.dto.Foo;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
@ -1,13 +1,10 @@
|
||||||
package org.baeldung.web.test;
|
package com.baeldung.web.test;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.baeldung.config.converter.KryoHttpMessageConverter;
|
|
||||||
import org.baeldung.web.dto.Foo;
|
|
||||||
import org.baeldung.web.dto.FooProtos;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
@ -18,6 +15,10 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
|
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.baeldung.config.converter.KryoHttpMessageConverter;
|
||||||
|
import com.baeldung.web.dto.Foo;
|
||||||
|
import com.baeldung.web.dto.FooProtos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration Test class. Tests methods hits the server's rest services.
|
* Integration Test class. Tests methods hits the server's rest services.
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.test;
|
package com.baeldung.web.test;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.baeldung.web.util;
|
package com.baeldung.web.util;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class RestTemplateBasicLiveTest {
|
||||||
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody()
|
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody()
|
||||||
.getId();
|
.getId();
|
||||||
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
|
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
|
||||||
final ClientHttpRequestFactory requestFactory = getSimpleClientHttpRequestFactory();
|
final ClientHttpRequestFactory requestFactory = getClientHttpRequestFactory();
|
||||||
final RestTemplate template = new RestTemplate(requestFactory);
|
final RestTemplate template = new RestTemplate(requestFactory);
|
||||||
template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter()));
|
template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter()));
|
||||||
template.patchForObject(resourceUrl, requestUpdate, Void.class);
|
template.patchForObject(resourceUrl, requestUpdate, Void.class);
|
||||||
|
@ -262,7 +262,7 @@ public class RestTemplateBasicLiveTest {
|
||||||
|
|
||||||
// Simply setting restTemplate timeout using ClientHttpRequestFactory
|
// Simply setting restTemplate timeout using ClientHttpRequestFactory
|
||||||
|
|
||||||
ClientHttpRequestFactory getSimpleClientHttpRequestFactory() {
|
ClientHttpRequestFactory getClientHttpRequestFactory() {
|
||||||
final int timeout = 5;
|
final int timeout = 5;
|
||||||
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
clientHttpRequestFactory.setConnectTimeout(timeout * 1000);
|
clientHttpRequestFactory.setConnectTimeout(timeout * 1000);
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Spring Security Login Page with Angular](https://www.baeldung.com/spring-security-login-angular)
|
- [Spring Security Login Page with Angular](https://www.baeldung.com/spring-security-login-angular)
|
||||||
- [Fixing 401s with CORS Preflights and Spring Security](https://www.baeldung.com/spring-security-cors-preflight)
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.baeldung.web.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class CustomController {
|
||||||
|
|
||||||
|
@RequestMapping(value = "/custom", method = RequestMethod.POST)
|
||||||
|
public String custom() {
|
||||||
|
return "custom";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
derby.log
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beansProjectDescription>
|
|
||||||
<version>1</version>
|
|
||||||
<pluginVersion><![CDATA[3.7.3.201602250914-RELEASE]]></pluginVersion>
|
|
||||||
<configSuffixes>
|
|
||||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
|
||||||
</configSuffixes>
|
|
||||||
<enableImports><![CDATA[false]]></enableImports>
|
|
||||||
<configs>
|
|
||||||
</configs>
|
|
||||||
<autoconfigs>
|
|
||||||
</autoconfigs>
|
|
||||||
<configSets>
|
|
||||||
</configSets>
|
|
||||||
</beansProjectDescription>
|
|
|
@ -1 +0,0 @@
|
||||||
spring-userservice is using a in memory derby db. Right click -> run on server to run the project
|
|
|
@ -1,240 +0,0 @@
|
||||||
<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>
|
|
||||||
<groupId>spring-userservice</groupId>
|
|
||||||
<artifactId>spring-userservice</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<packaging>war</packaging>
|
|
||||||
<name>spring-userservice</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-spring-4</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<relativePath>../parent-spring-4</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<!-- Spring -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-orm</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-context</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- persistence -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
|
||||||
<version>${hibernate.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-ehcache</artifactId>
|
|
||||||
<version>${hibernate.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>xml-apis</groupId>
|
|
||||||
<artifactId>xml-apis</artifactId>
|
|
||||||
<version>${xml-apis.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.javassist</groupId>
|
|
||||||
<artifactId>javassist</artifactId>
|
|
||||||
<version>${javassist.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<version>${mysql-connector-java.version}</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-jpa</artifactId>
|
|
||||||
<version>${spring-data-jpa.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
<version>${h2.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- validation -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>${hibernate-validator.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.el</groupId>
|
|
||||||
<artifactId>javax.el-api</artifactId>
|
|
||||||
<version>${javax.el-api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- utils -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>${guava.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- test scoped -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-test</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-core</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-web</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webmvc</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-core</artifactId>
|
|
||||||
<version>${org.springframework.security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-web</artifactId>
|
|
||||||
<version>${org.springframework.security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-config</artifactId>
|
|
||||||
<version>${org.springframework.security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.derby</groupId>
|
|
||||||
<artifactId>derby</artifactId>
|
|
||||||
<version>${derby.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.derby</groupId>
|
|
||||||
<artifactId>derbyclient</artifactId>
|
|
||||||
<version>${derby.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.derby</groupId>
|
|
||||||
<artifactId>derbynet</artifactId>
|
|
||||||
<version>${derby.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.derby</groupId>
|
|
||||||
<artifactId>derbytools</artifactId>
|
|
||||||
<version>${derby.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>taglibs</groupId>
|
|
||||||
<artifactId>standard</artifactId>
|
|
||||||
<version>${taglibs-standard.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-taglibs</artifactId>
|
|
||||||
<version>${org.springframework.security.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet.jsp.jstl</groupId>
|
|
||||||
<artifactId>jstl-api</artifactId>
|
|
||||||
<version>${jstl.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-test</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>${javax.servlet-api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>spring-userservice</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<version>${maven-war-plugin.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<!-- Spring -->
|
|
||||||
<org.springframework.security.version>4.2.6.RELEASE</org.springframework.security.version>
|
|
||||||
<spring-boot.version>1.5.14.RELEASE</spring-boot.version>
|
|
||||||
<javassist.version>3.21.0-GA</javassist.version>
|
|
||||||
|
|
||||||
<!-- persistence -->
|
|
||||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
|
||||||
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
|
|
||||||
<spring-data-jpa.version>1.10.5.RELEASE</spring-data-jpa.version>
|
|
||||||
<derby.version>10.13.1.1</derby.version>
|
|
||||||
|
|
||||||
<!-- various -->
|
|
||||||
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
|
|
||||||
<javax.el-api.version>2.2.5</javax.el-api.version>
|
|
||||||
<taglibs-standard.version>1.1.2</taglibs-standard.version>
|
|
||||||
|
|
||||||
<!-- util -->
|
|
||||||
<guava.version>19.0</guava.version>
|
|
||||||
<xml-apis.version>1.4.01</xml-apis.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,42 +0,0 @@
|
||||||
package org.baeldung.custom.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
||||||
import org.springframework.web.servlet.view.JstlView;
|
|
||||||
|
|
||||||
@EnableWebMvc
|
|
||||||
@Configuration
|
|
||||||
@ComponentScan(basePackages = { "org.baeldung.security" })
|
|
||||||
public class MvcConfig extends WebMvcConfigurerAdapter {
|
|
||||||
|
|
||||||
public MvcConfig() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addViewControllers(final ViewControllerRegistry registry) {
|
|
||||||
super.addViewControllers(registry);
|
|
||||||
|
|
||||||
registry.addViewController("/");
|
|
||||||
registry.addViewController("/index");
|
|
||||||
registry.addViewController("/login");
|
|
||||||
registry.addViewController("/register");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ViewResolver viewResolver() {
|
|
||||||
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
|
||||||
|
|
||||||
bean.setViewClass(JstlView.class);
|
|
||||||
bean.setPrefix("/WEB-INF/view/");
|
|
||||||
bean.setSuffix(".jsp");
|
|
||||||
|
|
||||||
return bean;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package org.baeldung.custom.config;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.persistence.EntityManagerFactory;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import org.baeldung.user.dao.MyUserDAO;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.PropertySource;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
|
||||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
|
||||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
|
||||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|
||||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
|
||||||
@PropertySource({ "classpath:persistence-derby.properties" })
|
|
||||||
public class PersistenceDerbyJPAConfig {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Environment env;
|
|
||||||
|
|
||||||
public PersistenceDerbyJPAConfig() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
// beans
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public LocalContainerEntityManagerFactoryBean myEmf() {
|
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
|
||||||
em.setDataSource(dataSource());
|
|
||||||
em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
|
|
||||||
|
|
||||||
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
|
||||||
em.setJpaVendorAdapter(vendorAdapter);
|
|
||||||
em.setJpaProperties(additionalProperties());
|
|
||||||
|
|
||||||
return em;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DataSource dataSource() {
|
|
||||||
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
|
||||||
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
|
|
||||||
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
|
|
||||||
dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
|
|
||||||
dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass")));
|
|
||||||
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
|
|
||||||
final JpaTransactionManager transactionManager = new JpaTransactionManager();
|
|
||||||
transactionManager.setEntityManagerFactory(emf);
|
|
||||||
return transactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
|
|
||||||
return new PersistenceExceptionTranslationPostProcessor();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Properties additionalProperties() {
|
|
||||||
final Properties hibernateProperties = new Properties();
|
|
||||||
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
|
|
||||||
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
|
|
||||||
hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache"));
|
|
||||||
hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache"));
|
|
||||||
// hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
|
|
||||||
return hibernateProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MyUserDAO myUserDAO() {
|
|
||||||
final MyUserDAO myUserDAO = new MyUserDAO();
|
|
||||||
return myUserDAO;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package org.baeldung.custom.config;
|
|
||||||
|
|
||||||
import org.baeldung.security.MyUserDetailsService;
|
|
||||||
import org.baeldung.user.service.MyUserService;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableWebSecurity
|
|
||||||
@Profile("!https")
|
|
||||||
public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
||||||
|
|
||||||
public SecSecurityConfig() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
|
||||||
// @formatter:off
|
|
||||||
auth.authenticationProvider(authenticationProvider());
|
|
||||||
// @formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(final HttpSecurity http) throws Exception {
|
|
||||||
// @formatter:off
|
|
||||||
http
|
|
||||||
.csrf().disable()
|
|
||||||
.authorizeRequests()
|
|
||||||
.antMatchers("/*").permitAll()
|
|
||||||
.and()
|
|
||||||
.formLogin()
|
|
||||||
.loginPage("/login")
|
|
||||||
.loginProcessingUrl("/login")
|
|
||||||
.defaultSuccessUrl("/",true)
|
|
||||||
.failureUrl("/login?error=true")
|
|
||||||
.and()
|
|
||||||
.logout()
|
|
||||||
.logoutUrl("/logout")
|
|
||||||
.deleteCookies("JSESSIONID")
|
|
||||||
.logoutSuccessUrl("/");
|
|
||||||
// @formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DaoAuthenticationProvider authenticationProvider() {
|
|
||||||
final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
|
|
||||||
authProvider.setUserDetailsService(myUserDetailsService());
|
|
||||||
authProvider.setPasswordEncoder(encoder());
|
|
||||||
return authProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PasswordEncoder encoder() {
|
|
||||||
return new BCryptPasswordEncoder(11);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MyUserDetailsService myUserDetailsService() {
|
|
||||||
return new MyUserDetailsService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MyUserService myUserService() {
|
|
||||||
return new MyUserService();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.baeldung.persistence.model;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(schema = "spring_custom_user_service")
|
|
||||||
public class MyUser {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
@Column(unique = true, nullable = false)
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
public MyUser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(final int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(final String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(final String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue