Conflicts: spring-data-mongodb/src/main/java/org/baeldung/config/MongoConfig.java
This commit is contained in:
commit
bddddbd090
@ -1,3 +1,10 @@
|
||||
|
||||
The "REST with Spring" Classes
|
||||
==============================
|
||||
This is what I'm working on: <br/>
|
||||
**[>> THE REST WITH SPRING CLASSES](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=50off)**
|
||||
|
||||
|
||||
Spring Tutorials
|
||||
================
|
||||
|
||||
|
@ -28,6 +28,12 @@
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
@ -0,0 +1,58 @@
|
||||
package org.baeldung.java8.base64;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ApacheCommonsEncodeDecodeTest {
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncoded() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final Base64 base64 = new Base64();
|
||||
final String encodedString = new String(base64.encode(originalInput.getBytes()));
|
||||
|
||||
assertNotNull(encodedString);
|
||||
assertNotEquals(originalInput, encodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncoded_thenStringCanBeDecoded() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final Base64 base64 = new Base64();
|
||||
final String encodedString = new String(base64.encode(originalInput.getBytes()));
|
||||
|
||||
final String decodedString = new String(base64.decode(encodedString.getBytes()));
|
||||
|
||||
assertNotNull(decodedString);
|
||||
assertEquals(originalInput, decodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedUsingStaticMethod() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = new String(Base64.encodeBase64(originalInput.getBytes()));
|
||||
|
||||
assertNotNull(encodedString);
|
||||
assertNotEquals(originalInput, encodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedUsingStaticMethod_thenStringCanBeDecodedUsingStaticMethod() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = new String(Base64.encodeBase64(originalInput.getBytes()));
|
||||
|
||||
final String decodedString = new String(Base64.decodeBase64(encodedString.getBytes()));
|
||||
|
||||
assertNotNull(decodedString);
|
||||
assertEquals(originalInput, decodedString);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package org.baeldung.java8.base64;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class Java8EncodeDecodeTest {
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncoded_thenOk() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes());
|
||||
|
||||
assertNotNull(encodedString);
|
||||
assertNotEquals(originalInput, encodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncoded_thenStringCanBeDecoded() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes());
|
||||
|
||||
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||
final String decodedString = new String(decodedBytes);
|
||||
|
||||
assertNotNull(decodedString);
|
||||
assertEquals(originalInput, decodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedWithoutPadding_thenOk() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = Base64.getEncoder().withoutPadding().encodeToString(originalInput.getBytes());
|
||||
|
||||
assertNotNull(encodedString);
|
||||
assertNotEquals(originalInput, encodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenStringIsEncodedWithoutPadding_thenStringCanBeDecoded() throws UnsupportedEncodingException {
|
||||
final String originalInput = "test input";
|
||||
final String encodedString = Base64.getEncoder().withoutPadding().encodeToString(originalInput.getBytes());
|
||||
|
||||
final byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
|
||||
final String decodedString = new String(decodedBytes);
|
||||
|
||||
assertNotNull(decodedString);
|
||||
assertEquals(originalInput, decodedString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUrlIsEncoded_thenOk() throws UnsupportedEncodingException {
|
||||
final String originalUrl = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java";
|
||||
final String encodedUrl = Base64.getUrlEncoder().encodeToString(originalUrl.getBytes());
|
||||
assertNotNull(encodedUrl);
|
||||
assertNotEquals(originalUrl, encodedUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUrlIsEncoded_thenURLCanBeDecoded() throws UnsupportedEncodingException {
|
||||
final String originalUrl = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java";
|
||||
final String encodedUrl = Base64.getUrlEncoder().encodeToString(originalUrl.getBytes());
|
||||
|
||||
final byte[] decodedBytes = Base64.getUrlDecoder().decode(encodedUrl.getBytes());
|
||||
final String decodedUrl = new String(decodedBytes);
|
||||
|
||||
assertNotNull(decodedUrl);
|
||||
assertEquals(originalUrl, decodedUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMimeIsEncoded_thenOk() throws UnsupportedEncodingException {
|
||||
final StringBuilder buffer = getMimeBuffer();
|
||||
|
||||
final byte[] forEncode = buffer.toString().getBytes();
|
||||
final String encodedMime = Base64.getMimeEncoder().encodeToString(forEncode);
|
||||
|
||||
assertNotNull(encodedMime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenMimeIsEncoded_thenItCanBeDecoded() throws UnsupportedEncodingException {
|
||||
final StringBuilder buffer = getMimeBuffer();
|
||||
|
||||
final byte[] forEncode = buffer.toString().getBytes();
|
||||
final String encodedMime = Base64.getMimeEncoder().encodeToString(forEncode);
|
||||
|
||||
final byte[] decodedBytes = Base64.getMimeDecoder().decode(encodedMime);
|
||||
final String decodedMime = new String(decodedBytes);
|
||||
assertNotNull(decodedMime);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
private static StringBuilder getMimeBuffer() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
for (int count = 0; count < 10; ++count) {
|
||||
buffer.append(UUID.randomUUID().toString());
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -128,12 +129,27 @@ public class JavaInputStreamToXUnitTest {
|
||||
// tests - InputStream to byte[]
|
||||
|
||||
@Test
|
||||
public final void givenUsingPlainJava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException {
|
||||
public final void givenUsingPlainJavaOnFixedSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException {
|
||||
final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 });
|
||||
final byte[] targetArray = new byte[initialStream.available()];
|
||||
initialStream.read(targetArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenUsingPlainJavaOnUnknownSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException {
|
||||
final InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 });
|
||||
|
||||
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
int nRead;
|
||||
final byte[] data = new byte[1024];
|
||||
while ((nRead = is.read(data, 0, data.length)) != -1) {
|
||||
buffer.write(data, 0, nRead);
|
||||
}
|
||||
|
||||
buffer.flush();
|
||||
final byte[] byteArray = buffer.toByteArray();
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenUsingGuava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException {
|
||||
final InputStream initialStream = ByteSource.wrap(new byte[] { 0, 1, 2 }).openStream();
|
||||
|
@ -7,6 +7,12 @@
|
||||
<name>spring-all</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.2.6.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring -->
|
||||
@ -14,22 +20,18 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- aspectj -->
|
||||
@ -37,13 +39,11 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- persistence -->
|
||||
@ -56,18 +56,15 @@
|
||||
<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.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- validation -->
|
||||
@ -75,7 +72,6 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
@ -83,14 +79,12 @@
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>${jstl.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@ -101,13 +95,33 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<!-- <scope>runtime</scope> -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||
</dependency>
|
||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test scoped -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@ -121,20 +135,17 @@
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<version>${org.hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>${org.hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -210,21 +221,21 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.19.0-GA</javassist.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
<jstl.version>1.2</jstl.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -245,7 +256,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
25
spring-all/src/main/java/org/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
vendored
Normal file
25
spring-all/src/main/java/org/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.properties.core")
|
||||
@PropertySource("classpath:foo.properties")
|
||||
public class ExternalPropertiesWithJavaConfig {
|
||||
|
||||
public ExternalPropertiesWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.properties.spring;
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -7,9 +7,9 @@ import org.springframework.context.annotation.ImportResource;
|
||||
@Configuration
|
||||
@ImportResource("classpath:configForProperties.xml")
|
||||
@ComponentScan("org.baeldung.core")
|
||||
public class PropertiesWithXmlConfig {
|
||||
public class ExternalPropertiesWithXmlConfig {
|
||||
|
||||
public PropertiesWithXmlConfig() {
|
||||
public ExternalPropertiesWithXmlConfig() {
|
||||
super();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.baeldung.properties.spring;
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -7,9 +7,9 @@ import org.springframework.context.annotation.ImportResource;
|
||||
@Configuration
|
||||
@ImportResource("classpath:configForPropertiesOne.xml")
|
||||
@ComponentScan("org.baeldung.core")
|
||||
public class PropertiesWithXmlConfigOne {
|
||||
public class ExternalPropertiesWithXmlConfigOne {
|
||||
|
||||
public PropertiesWithXmlConfigOne() {
|
||||
public ExternalPropertiesWithXmlConfigOne() {
|
||||
super();
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:basicConfigForPropertiesTwo.xml")
|
||||
public class ExternalPropertiesWithXmlConfigTwo {
|
||||
|
||||
public ExternalPropertiesWithXmlConfigTwo() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.baeldung.properties.spring;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:foo.properties")
|
||||
public class BasicPropertiesWithJavaConfig {
|
||||
|
||||
public BasicPropertiesWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
package org.baeldung.properties.spring;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.properties.core")
|
||||
@PropertySource("classpath:foo.properties")
|
||||
public class PropertiesWithJavaConfig {
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
package org.baeldung.properties.spring;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@Configuration
|
||||
@ImportResource("classpath:configForPropertiesTwo.xml")
|
||||
public class PropertiesWithXmlConfigTwo {
|
||||
|
||||
public PropertiesWithXmlConfigTwo() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package org.baeldung.spring.config;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public final class CleanupBean implements DisposableBean {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private ExecutorService setupExecutor;
|
||||
|
||||
public CleanupBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info("Starting shutdown process - cleanup");
|
||||
|
||||
setupExecutor.shutdownNow();
|
||||
|
||||
logger.info("Finishing shutdown process - cleanup");
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
package org.baeldung.spring.config;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
@ -12,4 +18,15 @@ public class CoreConfig extends WebMvcConfigurerAdapter {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
@Bean
|
||||
public ExecutorService setupExecutor() {
|
||||
final int coreThreads = 4;
|
||||
final int maxThreads = 8;
|
||||
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(coreThreads, maxThreads, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
||||
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
||||
return threadPoolExecutor;
|
||||
}
|
||||
|
||||
}
|
12
spring-all/src/main/resources/basicConfigForProperties.xml
Normal file
12
spring-all/src/main/resources/basicConfigForProperties.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
|
||||
>
|
||||
|
||||
<context:property-placeholder location="classpath:foo.properties"/>
|
||||
|
||||
</beans>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
|
||||
>
|
||||
|
||||
<context:property-placeholder location="classpath:foo.properties" ignore-unresolvable="true" order="1"/>
|
||||
|
||||
</beans>
|
@ -2,9 +2,9 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
||||
>
|
||||
|
||||
<context:property-placeholder location="classpath:springScheduled.properties"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.basic;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfig;
|
||||
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -11,8 +11,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class PropertiesWithXmlIntegrationTest {
|
||||
@ContextConfiguration(classes = { BasicPropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class BasicPropertiesWithJavaIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
@ -1,7 +1,7 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.basic;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfigOne;
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo;
|
||||
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
|
||||
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -12,8 +12,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class PropertiesWithMultipleXmlsIntegrationTest {
|
||||
@ContextConfiguration(classes = { BasicPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class ExtendedPropertiesWithJavaIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
@ -1,7 +1,6 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.basic;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
|
||||
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -12,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class PropertiesWithJavaIntegrationTest {
|
||||
|
||||
@Autowired
|
@ -0,0 +1,27 @@
|
||||
package org.baeldung.properties.basic;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:basicConfigForPropertiesOne.xml", "classpath:basicConfigForPropertiesTwo.xml" })
|
||||
public class PropertiesWithMultipleXmlsIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Value("${key.something}")
|
||||
private String injectedProperty;
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
System.out.println("in test via @Value: " + injectedProperty);
|
||||
System.out.println("in test Environment: " + env.getProperty("key.something"));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.baeldung.properties.basic;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "classpath:basicConfigForProperties.xml")
|
||||
public class PropertiesWithXmlIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Value("${key.something}")
|
||||
private String injectedProperty;
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
System.out.println("in test via @Value: " + injectedProperty);
|
||||
System.out.println("in test Environment: " + env.getProperty("key.something"));
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
|
||||
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@ -13,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ExternalPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@Ignore("manual only")
|
||||
public class ExternalPropertiesWithJavaIntegrationTest {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfigOne;
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -13,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithXmlConfigOne.class, PropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfigOne.class, ExternalPropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@Ignore("manual only")
|
||||
public class ExternalPropertiesWithMultipleXmlsIntegrationTest {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.baeldung.properties.core;
|
||||
package org.baeldung.properties.external;
|
||||
|
||||
import org.baeldung.properties.spring.PropertiesWithXmlConfig;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -12,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@Ignore("manual only")
|
||||
public class ExternalPropertiesWithXmlIntegrationTest {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.baeldung.test;
|
||||
|
||||
import org.baeldung.properties.core.ExternalPropertiesWithJavaIntegrationTest;
|
||||
import org.baeldung.properties.core.ExternalPropertiesWithMultipleXmlsIntegrationTest;
|
||||
import org.baeldung.properties.core.ExternalPropertiesWithXmlIntegrationTest;
|
||||
import org.baeldung.properties.core.PropertiesWithJavaIntegrationTest;
|
||||
import org.baeldung.properties.core.PropertiesWithMultipleXmlsIntegrationTest;
|
||||
import org.baeldung.properties.core.PropertiesWithXmlIntegrationTest;
|
||||
import org.baeldung.properties.basic.ExtendedPropertiesWithJavaIntegrationTest;
|
||||
import org.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest;
|
||||
import org.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
|
||||
import org.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
|
||||
import org.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest;
|
||||
import org.baeldung.properties.external.ExternalPropertiesWithXmlIntegrationTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
@ -16,7 +16,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
ExternalPropertiesWithJavaIntegrationTest.class,
|
||||
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
|
||||
ExternalPropertiesWithXmlIntegrationTest.class,
|
||||
PropertiesWithJavaIntegrationTest.class,
|
||||
ExtendedPropertiesWithJavaIntegrationTest.class,
|
||||
PropertiesWithMultipleXmlsIntegrationTest.class,
|
||||
})// @formatter:on
|
||||
public final class IntegrationTestSuite {
|
||||
|
@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.2.4.RELEASE</version>
|
||||
<version>1.2.6.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,18 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>spring-data-mongodb</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<name>spring-data-mongodb</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.springframework.ide.eclipse.core.springnature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
@ -8,10 +8,10 @@ import org.baeldung.event.CascadeSaveMongoEventListener;
|
||||
import org.baeldung.event.UserCascadeSaveMongoEventListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
|
||||
import org.springframework.data.mongodb.core.convert.CustomConversions;
|
||||
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
@ -21,7 +21,7 @@ import com.mongodb.MongoClient;
|
||||
@EnableMongoRepositories(basePackages = "org.baeldung.repository")
|
||||
public class MongoConfig extends AbstractMongoConfiguration {
|
||||
|
||||
private List<Converter<?, ?>> converters = new ArrayList<Converter<?, ?>>();
|
||||
private final List<Converter<?, ?>> converters = new ArrayList<Converter<?, ?>>();
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.baeldung.converter;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.baeldung.model.User;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
@ -10,12 +10,12 @@ import com.mongodb.DBObject;
|
||||
@Component
|
||||
public class UserWriterConverter implements Converter<User, DBObject> {
|
||||
@Override
|
||||
public DBObject convert(User user) {
|
||||
DBObject dbObject = new BasicDBObject();
|
||||
public DBObject convert(final User user) {
|
||||
final DBObject dbObject = new BasicDBObject();
|
||||
dbObject.put("name", user.getName());
|
||||
dbObject.put("age", user.getAge());
|
||||
if (user.getEmailAddress() != null) {
|
||||
DBObject emailDbObject = new BasicDBObject();
|
||||
final DBObject emailDbObject = new BasicDBObject();
|
||||
emailDbObject.put("value", user.getEmailAddress().getValue());
|
||||
dbObject.put("email", emailDbObject);
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
public void doWith(final Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
|
||||
if (field.isAnnotationPresent(DBRef.class) && field.isAnnotationPresent(CascadeSave.class)) {
|
||||
final Object fieldValue = field.get(getSource());
|
||||
|
||||
if (fieldValue != null) {
|
||||
FieldCallback callback = new FieldCallback();
|
||||
final FieldCallback callback = new FieldCallback();
|
||||
|
||||
ReflectionUtils.doWithFields(fieldValue.getClass(), callback);
|
||||
|
||||
@ -39,7 +39,7 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(Object source) {
|
||||
public void setSource(final Object source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback {
|
||||
return mongoOperations;
|
||||
}
|
||||
|
||||
public void setMongoOperations(MongoOperations mongoOperations) {
|
||||
public void setMongoOperations(final MongoOperations mongoOperations) {
|
||||
this.mongoOperations = mongoOperations;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
public class FieldCallback implements ReflectionUtils.FieldCallback {
|
||||
private boolean idFound;
|
||||
|
||||
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
@Override
|
||||
public void doWith(final Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
|
||||
if (field.isAnnotationPresent(Id.class)) {
|
||||
|
@ -73,7 +73,7 @@ public class User {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(EmailAddress emailAddress) {
|
||||
public void setEmailAddress(final EmailAddress emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public class User {
|
||||
return yearOfBirth;
|
||||
}
|
||||
|
||||
public void setYearOfBirth(Integer yearOfBirth) {
|
||||
public void setYearOfBirth(final Integer yearOfBirth) {
|
||||
this.yearOfBirth = yearOfBirth;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package org.baeldung.repository;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.model.User;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
|
@ -26,7 +26,6 @@ import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class MongoTemplateQueryIntegrationTest {
|
||||
|
@ -3,7 +3,6 @@ package org.baeldung.repository;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.config.MongoConfig;
|
||||
@ -13,7 +12,6 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
@ -32,7 +30,7 @@ public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
List<User> users = userRepository.findByName("Eric");
|
||||
assertThat(users.size(), is(1));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUsersExist_whenFindingUsersWithAgeCreaterThanAndLessThan_thenUsersAreFound() {
|
||||
User user = new User();
|
||||
@ -53,7 +51,7 @@ public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
List<User> users = userRepository.findByAgeBetween(26, 40);
|
||||
assertThat(users.size(), is(1));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUsersExist_whenFindingUserWithNameStartWithA_thenUsersAreFound() {
|
||||
User user = new User();
|
||||
@ -74,7 +72,7 @@ public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
List<User> users = userRepository.findByNameStartingWith("A");
|
||||
assertThat(users.size(), is(2));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUsersExist_whenFindingUserWithNameEndWithC_thenUsersAreFound() {
|
||||
User user = new User();
|
||||
@ -93,10 +91,10 @@ public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
mongoOps.insert(user);
|
||||
|
||||
List<User> users = userRepository.findByNameEndingWith("c");
|
||||
|
||||
|
||||
assertThat(users.size(), is(1));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUsersExist_whenFindingUsersAndSortThem_thenUsersAreFoundAndSorted() {
|
||||
User user = new User();
|
||||
@ -115,8 +113,7 @@ public class QueryMethodsIntegrationTest extends BaseQueryIntegrationTest {
|
||||
mongoOps.insert(user);
|
||||
|
||||
List<User> users = userRepository.findByNameLikeOrderByAgeAsc("A");
|
||||
|
||||
|
||||
assertThat(users.size(), is(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -203,14 +203,14 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.19.0-GA</javassist.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
<jstl.version>1.2</jstl.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
<tomcat-dbcp.version>7.0.42</tomcat-dbcp.version>
|
||||
|
||||
<!-- logging -->
|
||||
@ -218,7 +218,7 @@
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -240,7 +240,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -162,13 +162,13 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.19.0-GA</javassist.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>3.6.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
<tomcat-dbcp.version>7.0.47</tomcat-dbcp.version>
|
||||
|
||||
<!-- logging -->
|
||||
@ -176,7 +176,7 @@
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -196,7 +196,7 @@
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -169,13 +169,13 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.19.0-GA</javassist.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
<tomcat-dbcp.version>7.0.42</tomcat-dbcp.version>
|
||||
|
||||
<!-- logging -->
|
||||
@ -183,7 +183,7 @@
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -203,7 +203,7 @@
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -174,13 +174,13 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<javassist.version>3.19.0-GA</javassist.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.version>4.0.2.RELEASE</org.springframework.version>
|
||||
<javassist.version>3.20.0-GA</javassist.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
<spring-data-jpa.version>1.7.2.RELEASE</spring-data-jpa.version>
|
||||
|
||||
<!-- logging -->
|
||||
@ -188,7 +188,7 @@
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -208,7 +208,7 @@
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
<!-- <maven-war-plugin.version>2.6</maven-war-plugin.version> -->
|
||||
|
||||
</properties>
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -140,19 +140,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -173,7 +173,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -144,7 +144,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
@ -165,7 +165,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -146,7 +146,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
@ -167,7 +167,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="cloudfoundry.standalone.app" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
</faceted-project>
|
||||
|
@ -6,4 +6,4 @@
|
||||
### Relevant Articles:
|
||||
- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping)
|
||||
- [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest)
|
||||
- [Redirect in Spring](http://www.baeldung.com/spring-redirect)
|
||||
- [Redirect in Spring](http://www.baeldung.com/spring-redirect-and-forward)
|
||||
|
@ -229,19 +229,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
|
||||
<jackson.version>2.5.1</jackson.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -265,7 +265,7 @@
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -225,19 +225,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -258,7 +258,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<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>org.baeldung</groupId>
|
||||
<artifactId>spring-security-login-and-registration</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
|
||||
<name>spring-security-login-and-registration</name>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.2.5.RELEASE</version>
|
||||
<version>1.2.6.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -188,13 +190,34 @@
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.cargo</groupId>
|
||||
<artifactId>cargo-maven2-plugin</artifactId>
|
||||
<version>${cargo-maven2-plugin.version}</version>
|
||||
<configuration>
|
||||
<wait>true</wait>
|
||||
<container>
|
||||
<containerId>tomcat8x</containerId>
|
||||
<type>embedded</type>
|
||||
<systemProperties>
|
||||
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
||||
</systemProperties>
|
||||
</container>
|
||||
<configuration>
|
||||
<properties>
|
||||
<cargo.servlet.port>8081</cargo.servlet.port>
|
||||
</properties>
|
||||
</configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java-version>1.7</java-version>
|
||||
<org.springframework-version>4.1.6.RELEASE</org.springframework-version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
@ -212,5 +235,9 @@
|
||||
<!-- guava -->
|
||||
<guava.version>18.0</guava.version>
|
||||
|
||||
<!-- maven -->
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -6,7 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PasswordResetTokenRepository extends JpaRepository<PasswordResetToken, Long> {
|
||||
|
||||
public PasswordResetToken findByToken(String token);
|
||||
PasswordResetToken findByToken(String token);
|
||||
|
||||
PasswordResetToken findByUser(User user);
|
||||
|
||||
public PasswordResetToken findByUser(User user);
|
||||
}
|
||||
|
@ -4,7 +4,10 @@ import org.baeldung.persistence.model.Privilege;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
|
||||
public Privilege findByName(String name);
|
||||
|
||||
public void delete(Privilege privilege);
|
||||
Privilege findByName(String name);
|
||||
|
||||
@Override
|
||||
void delete(Privilege privilege);
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,10 @@ import org.baeldung.persistence.model.Role;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface RoleRepository extends JpaRepository<Role, Long> {
|
||||
public Role findByName(String name);
|
||||
|
||||
public void delete(Role role);
|
||||
Role findByName(String name);
|
||||
|
||||
@Override
|
||||
void delete(Role role);
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package org.baeldung.persistence.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.baeldung.persistence.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
public User findByEmail(String email);
|
||||
User findByEmail(String email);
|
||||
|
||||
public void delete(User user);
|
||||
@Override
|
||||
void delete(User user);
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface VerificationTokenRepository extends JpaRepository<VerificationToken, Long> {
|
||||
|
||||
public VerificationToken findByToken(String token);
|
||||
VerificationToken findByToken(String token);
|
||||
|
||||
VerificationToken findByUser(User user);
|
||||
|
||||
public VerificationToken findByUser(User user);
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ public class PasswordResetToken {
|
||||
super();
|
||||
}
|
||||
|
||||
public PasswordResetToken(String token) {
|
||||
public PasswordResetToken(final String token) {
|
||||
super();
|
||||
|
||||
this.token = token;
|
||||
this.expiryDate = calculateExpiryDate(EXPIRATION);
|
||||
}
|
||||
|
||||
public PasswordResetToken(String token, User user) {
|
||||
public PasswordResetToken(final String token, final User user) {
|
||||
super();
|
||||
|
||||
this.token = token;
|
||||
@ -47,11 +47,13 @@ public class PasswordResetToken {
|
||||
this.expiryDate = calculateExpiryDate(EXPIRATION);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
public void setToken(final String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@ -59,7 +61,7 @@ public class PasswordResetToken {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
public void setUser(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@ -67,18 +69,18 @@ public class PasswordResetToken {
|
||||
return expiryDate;
|
||||
}
|
||||
|
||||
public void setExpiryDate(Date expiryDate) {
|
||||
public void setExpiryDate(final Date expiryDate) {
|
||||
this.expiryDate = expiryDate;
|
||||
}
|
||||
|
||||
private Date calculateExpiryDate(int expiryTimeInMinutes) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
private Date calculateExpiryDate(final int expiryTimeInMinutes) {
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(new Date().getTime());
|
||||
cal.add(Calendar.MINUTE, expiryTimeInMinutes);
|
||||
return new Date(cal.getTime().getTime());
|
||||
}
|
||||
|
||||
public void updateToken(String token) {
|
||||
public void updateToken(final String token) {
|
||||
this.token = token;
|
||||
this.expiryDate = calculateExpiryDate(EXPIRATION);
|
||||
}
|
||||
@ -96,29 +98,38 @@ public class PasswordResetToken {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
PasswordResetToken other = (PasswordResetToken) obj;
|
||||
}
|
||||
final PasswordResetToken other = (PasswordResetToken) obj;
|
||||
if (expiryDate == null) {
|
||||
if (other.expiryDate != null)
|
||||
if (other.expiryDate != null) {
|
||||
return false;
|
||||
} else if (!expiryDate.equals(other.expiryDate))
|
||||
}
|
||||
} else if (!expiryDate.equals(other.expiryDate)) {
|
||||
return false;
|
||||
}
|
||||
if (token == null) {
|
||||
if (other.token != null)
|
||||
if (other.token != null) {
|
||||
return false;
|
||||
} else if (!token.equals(other.token))
|
||||
}
|
||||
} else if (!token.equals(other.token)) {
|
||||
return false;
|
||||
}
|
||||
if (user == null) {
|
||||
if (other.user != null)
|
||||
if (other.user != null) {
|
||||
return false;
|
||||
} else if (!user.equals(other.user))
|
||||
}
|
||||
} else if (!user.equals(other.user)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import javax.persistence.ManyToMany;
|
||||
|
||||
@Entity
|
||||
public class Privilege {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@ -23,16 +24,18 @@ public class Privilege {
|
||||
super();
|
||||
}
|
||||
|
||||
public Privilege(String name) {
|
||||
public Privilege(final String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -40,7 +43,7 @@ public class Privilege {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -48,7 +51,7 @@ public class Privilege {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Collection<Role> roles) {
|
||||
public void setRoles(final Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@ -62,15 +65,19 @@ public class Privilege {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Privilege privilege = (Privilege) obj;
|
||||
if (!privilege.equals(privilege.name))
|
||||
if (!privilege.equals(privilege.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,9 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.JoinColumn;
|
||||
|
||||
@Entity
|
||||
public class Role {
|
||||
@ -30,16 +30,18 @@ public class Role {
|
||||
super();
|
||||
}
|
||||
|
||||
public Role(String name) {
|
||||
public Role(final String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -47,7 +49,7 @@ public class Role {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -55,7 +57,7 @@ public class Role {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Collection<User> users) {
|
||||
public void setUsers(final Collection<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@ -63,7 +65,7 @@ public class Role {
|
||||
return privileges;
|
||||
}
|
||||
|
||||
public void setPrivileges(Collection<Privilege> privileges) {
|
||||
public void setPrivileges(final Collection<Privilege> privileges) {
|
||||
this.privileges = privileges;
|
||||
}
|
||||
|
||||
@ -77,15 +79,19 @@ public class Role {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Role role = (Role) obj;
|
||||
if (!role.equals(role.name))
|
||||
if (!role.equals(role.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ public class User {
|
||||
|
||||
private boolean tokenExpired;
|
||||
|
||||
//
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id") )
|
||||
private Collection<Role> roles;
|
||||
@ -45,7 +47,7 @@ public class User {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -53,7 +55,7 @@ public class User {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
public void setFirstName(final String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
@ -61,7 +63,7 @@ public class User {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
public void setLastName(final String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ public class User {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String username) {
|
||||
public void setEmail(final String username) {
|
||||
this.email = username;
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ public class User {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@ -85,7 +87,7 @@ public class User {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Collection<Role> roles) {
|
||||
public void setRoles(final Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@ -93,7 +95,7 @@ public class User {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@ -101,7 +103,7 @@ public class User {
|
||||
return tokenExpired;
|
||||
}
|
||||
|
||||
public void setTokenExpired(boolean expired) {
|
||||
public void setTokenExpired(final boolean expired) {
|
||||
this.tokenExpired = expired;
|
||||
}
|
||||
|
||||
@ -115,15 +117,19 @@ public class User {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final User user = (User) obj;
|
||||
if (!email.equals(user.email))
|
||||
if (!email.equals(user.email)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -32,14 +32,14 @@ public class VerificationToken {
|
||||
super();
|
||||
}
|
||||
|
||||
public VerificationToken(String token) {
|
||||
public VerificationToken(final String token) {
|
||||
super();
|
||||
|
||||
this.token = token;
|
||||
this.expiryDate = calculateExpiryDate(EXPIRATION);
|
||||
}
|
||||
|
||||
public VerificationToken(String token, User user) {
|
||||
public VerificationToken(final String token, final User user) {
|
||||
super();
|
||||
|
||||
this.token = token;
|
||||
@ -51,7 +51,7 @@ public class VerificationToken {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
public void setToken(final String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public class VerificationToken {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
public void setUser(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@ -67,18 +67,18 @@ public class VerificationToken {
|
||||
return expiryDate;
|
||||
}
|
||||
|
||||
public void setExpiryDate(Date expiryDate) {
|
||||
public void setExpiryDate(final Date expiryDate) {
|
||||
this.expiryDate = expiryDate;
|
||||
}
|
||||
|
||||
private Date calculateExpiryDate(int expiryTimeInMinutes) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
private Date calculateExpiryDate(final int expiryTimeInMinutes) {
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(new Date().getTime());
|
||||
cal.add(Calendar.MINUTE, expiryTimeInMinutes);
|
||||
return new Date(cal.getTime().getTime());
|
||||
}
|
||||
|
||||
public void updateToken(String token) {
|
||||
public void updateToken(final String token) {
|
||||
this.token = token;
|
||||
this.expiryDate = calculateExpiryDate(EXPIRATION);
|
||||
}
|
||||
@ -96,29 +96,38 @@ public class VerificationToken {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
VerificationToken other = (VerificationToken) obj;
|
||||
}
|
||||
final VerificationToken other = (VerificationToken) obj;
|
||||
if (expiryDate == null) {
|
||||
if (other.expiryDate != null)
|
||||
if (other.expiryDate != null) {
|
||||
return false;
|
||||
} else if (!expiryDate.equals(other.expiryDate))
|
||||
}
|
||||
} else if (!expiryDate.equals(other.expiryDate)) {
|
||||
return false;
|
||||
}
|
||||
if (token == null) {
|
||||
if (other.token != null)
|
||||
if (other.token != null) {
|
||||
return false;
|
||||
} else if (!token.equals(other.token))
|
||||
}
|
||||
} else if (!token.equals(other.token)) {
|
||||
return false;
|
||||
}
|
||||
if (user == null) {
|
||||
if (other.user != null)
|
||||
if (other.user != null) {
|
||||
return false;
|
||||
} else if (!user.equals(other.user))
|
||||
}
|
||||
} else if (!user.equals(other.user)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,5 @@ public interface IUserService {
|
||||
void changeUserPassword(User user, String password);
|
||||
|
||||
boolean checkIfValidOldPassword(User user, String password);
|
||||
|
||||
}
|
||||
|
@ -12,13 +12,15 @@ public class OnRegistrationCompleteEvent extends ApplicationEvent {
|
||||
private final Locale locale;
|
||||
private final User user;
|
||||
|
||||
public OnRegistrationCompleteEvent(User user, Locale locale, String appUrl) {
|
||||
public OnRegistrationCompleteEvent(final User user, final Locale locale, final String appUrl) {
|
||||
super(user);
|
||||
this.user = user;
|
||||
this.locale = locale;
|
||||
this.appUrl = appUrl;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public String getAppUrl() {
|
||||
return appUrl;
|
||||
}
|
||||
@ -30,4 +32,5 @@ public class OnRegistrationCompleteEvent extends ApplicationEvent {
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,13 +30,13 @@ public class RegistrationListener implements ApplicationListener<OnRegistrationC
|
||||
// API
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(OnRegistrationCompleteEvent event) {
|
||||
public void onApplicationEvent(final OnRegistrationCompleteEvent event) {
|
||||
this.confirmRegistration(event);
|
||||
}
|
||||
|
||||
private void confirmRegistration(OnRegistrationCompleteEvent event) {
|
||||
User user = event.getUser();
|
||||
String token = UUID.randomUUID().toString();
|
||||
private void confirmRegistration(final OnRegistrationCompleteEvent event) {
|
||||
final User user = event.getUser();
|
||||
final String token = UUID.randomUUID().toString();
|
||||
service.createVerificationTokenForUser(user, token);
|
||||
|
||||
final SimpleMailMessage email = constructEmailMessage(event, user, token);
|
||||
|
@ -12,10 +12,12 @@ public class AuthenticationFailureListener implements ApplicationListener<Authen
|
||||
@Autowired
|
||||
private LoginAttemptService loginAttemptService;
|
||||
|
||||
public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent e) {
|
||||
WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails();
|
||||
@Override
|
||||
public void onApplicationEvent(final AuthenticationFailureBadCredentialsEvent e) {
|
||||
final WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails();
|
||||
if (auth != null) {
|
||||
loginAttemptService.loginFailed(auth.getRemoteAddress());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -12,10 +12,12 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A
|
||||
@Autowired
|
||||
private LoginAttemptService loginAttemptService;
|
||||
|
||||
public void onApplicationEvent(AuthenticationSuccessEvent e) {
|
||||
WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails();
|
||||
@Override
|
||||
public void onApplicationEvent(final AuthenticationSuccessEvent e) {
|
||||
final WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails();
|
||||
if (auth != null) {
|
||||
loginAttemptService.loginSucceeded(auth.getRemoteAddress());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,31 +18,34 @@ public class LoginAttemptService {
|
||||
public LoginAttemptService() {
|
||||
super();
|
||||
attemptsCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).build(new CacheLoader<String, Integer>() {
|
||||
public Integer load(String key) {
|
||||
@Override
|
||||
public Integer load(final String key) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loginSucceeded(String key) {
|
||||
//
|
||||
|
||||
public void loginSucceeded(final String key) {
|
||||
attemptsCache.invalidate(key);
|
||||
}
|
||||
|
||||
public void loginFailed(String key) {
|
||||
public void loginFailed(final String key) {
|
||||
int attempts = 0;
|
||||
try {
|
||||
attempts = attemptsCache.get(key);
|
||||
} catch (ExecutionException e) {
|
||||
} catch (final ExecutionException e) {
|
||||
attempts = 0;
|
||||
}
|
||||
attempts++;
|
||||
attemptsCache.put(key, attempts);
|
||||
}
|
||||
|
||||
public boolean isBlocked(String key) {
|
||||
public boolean isBlocked(final String key) {
|
||||
try {
|
||||
return attemptsCache.get(key) >= MAX_ATTEMPT;
|
||||
} catch (ExecutionException e) {
|
||||
} catch (final ExecutionException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -23,17 +23,18 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
||||
|
||||
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
|
||||
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
||||
@Override
|
||||
public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException {
|
||||
handle(request, response, authentication);
|
||||
HttpSession session = request.getSession(false);
|
||||
final HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
session.setMaxInactiveInterval(30);
|
||||
session.setMaxInactiveInterval(30 * 60);
|
||||
}
|
||||
clearAuthenticationAttributes(request);
|
||||
}
|
||||
|
||||
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
||||
String targetUrl = determineTargetUrl(authentication);
|
||||
protected void handle(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException {
|
||||
final String targetUrl = determineTargetUrl(authentication);
|
||||
|
||||
if (response.isCommitted()) {
|
||||
logger.debug("Response has already been committed. Unable to redirect to " + targetUrl);
|
||||
@ -43,11 +44,11 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
||||
redirectStrategy.sendRedirect(request, response, targetUrl);
|
||||
}
|
||||
|
||||
protected String determineTargetUrl(Authentication authentication) {
|
||||
protected String determineTargetUrl(final Authentication authentication) {
|
||||
boolean isUser = false;
|
||||
boolean isAdmin = false;
|
||||
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
|
||||
for (GrantedAuthority grantedAuthority : authorities) {
|
||||
final Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
|
||||
for (final GrantedAuthority grantedAuthority : authorities) {
|
||||
if (grantedAuthority.getAuthority().equals("READ_PRIVILEGE")) {
|
||||
isUser = true;
|
||||
} else if (grantedAuthority.getAuthority().equals("WRITE_PRIVILEGE")) {
|
||||
@ -65,15 +66,15 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearAuthenticationAttributes(HttpServletRequest request) {
|
||||
HttpSession session = request.getSession(false);
|
||||
protected void clearAuthenticationAttributes(final HttpServletRequest request) {
|
||||
final HttpSession session = request.getSession(false);
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
|
||||
}
|
||||
|
||||
public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
|
||||
public void setRedirectStrategy(final RedirectStrategy redirectStrategy) {
|
||||
this.redirectStrategy = redirectStrategy;
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,7 @@ import org.baeldung.persistence.dao.UserRepository;
|
||||
import org.baeldung.persistence.model.Privilege;
|
||||
import org.baeldung.persistence.model.Role;
|
||||
import org.baeldung.persistence.model.User;
|
||||
import org.baeldung.persistence.service.IUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@ -29,10 +27,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
@Autowired
|
||||
private IUserService service;
|
||||
@Autowired
|
||||
private MessageSource messages;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@ -50,7 +45,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException {
|
||||
String ip = request.getRemoteAddr();
|
||||
final String ip = request.getRemoteAddr();
|
||||
if (loginAttemptService.isBlocked(ip)) {
|
||||
throw new RuntimeException("blocked");
|
||||
}
|
||||
@ -76,7 +71,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
private final List<String> getPrivileges(final Collection<Role> roles) {
|
||||
final List<String> privileges = new ArrayList<String>();
|
||||
final List<Privilege> collection = new ArrayList<Privilege>();
|
||||
for (Role role : roles) {
|
||||
for (final Role role : roles) {
|
||||
collection.addAll(role.getPrivileges());
|
||||
}
|
||||
for (final Privilege item : collection) {
|
||||
@ -92,4 +87,5 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ public class AppConfig {
|
||||
|
||||
@Bean
|
||||
public JavaMailSenderImpl javaMailSenderImpl() {
|
||||
JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl();
|
||||
final JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl();
|
||||
mailSenderImpl.setHost(env.getProperty("smtp.host"));
|
||||
mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class));
|
||||
mailSenderImpl.setProtocol(env.getProperty("smtp.protocol"));
|
||||
mailSenderImpl.setUsername(env.getProperty("smtp.username"));
|
||||
mailSenderImpl.setPassword(env.getProperty("smtp.password"));
|
||||
Properties javaMailProps = new Properties();
|
||||
final Properties javaMailProps = new Properties();
|
||||
javaMailProps.put("mail.smtp.auth", true);
|
||||
javaMailProps.put("mail.smtp.starttls.enable", true);
|
||||
mailSenderImpl.setJavaMailProperties(javaMailProps);
|
||||
|
@ -53,13 +53,13 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
|
||||
public void addInterceptors(final InterceptorRegistry registry) {
|
||||
final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
|
||||
localeChangeInterceptor.setParamName("lang");
|
||||
registry.addInterceptor(localeChangeInterceptor);
|
||||
}
|
||||
@ -77,14 +77,14 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
||||
final CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
|
||||
cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH);
|
||||
return cookieLocaleResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource() {
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.setBasename("classpath:messages");
|
||||
messageSource.setUseCodeAsDefaultMessage(true);
|
||||
messageSource.setDefaultEncoding("UTF-8");
|
||||
|
@ -32,6 +32,8 @@ public class PersistenceJPAConfig {
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
|
@ -47,8 +47,8 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.csrf().disable()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/j_spring_security_check*","/login*", "/logout*", "/signin/**", "/signup/**",
|
||||
"/user/registration*", "/regitrationConfirm*", "/expiredAccount*", "/registration*",
|
||||
"/badUser*", "/user/resendRegistrationToken*" ,"/forgetPassword*", "/user/resetPassword*",
|
||||
"/user/registration*", "/regitrationConfirm*", "/expiredAccount*", "/registration*",
|
||||
"/badUser*", "/user/resendRegistrationToken*" ,"/forgetPassword*", "/user/resetPassword*",
|
||||
"/user/changePassword*", "/emailError*", "/resources/**","/old/user/registration*","/successRegister*").permitAll()
|
||||
.antMatchers("/invalidSession*").anonymous()
|
||||
.anyRequest().authenticated()
|
||||
|
@ -3,7 +3,8 @@ package org.baeldung.validation;
|
||||
@SuppressWarnings("serial")
|
||||
public class EmailExistsException extends Throwable {
|
||||
|
||||
public EmailExistsException(String message) {
|
||||
public EmailExistsException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,15 +12,15 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
|
||||
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
|
||||
|
||||
@Override
|
||||
public void initialize(ValidEmail constraintAnnotation) {
|
||||
public void initialize(final ValidEmail constraintAnnotation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String username, ConstraintValidatorContext context) {
|
||||
public boolean isValid(final String username, final ConstraintValidatorContext context) {
|
||||
return (validateEmail(username));
|
||||
}
|
||||
|
||||
private boolean validateEmail(String email) {
|
||||
private boolean validateEmail(final String email) {
|
||||
pattern = Pattern.compile(EMAIL_PATTERN);
|
||||
matcher = pattern.matcher(email);
|
||||
return matcher.matches();
|
||||
|
@ -1,14 +1,15 @@
|
||||
package org.baeldung.validation;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
|
||||
@Target({ TYPE, ANNOTATION_TYPE })
|
||||
@Retention(RUNTIME)
|
||||
@ -21,4 +22,5 @@ public @interface PasswordMatches {
|
||||
Class<?>[]groups() default {};
|
||||
|
||||
Class<? extends Payload>[]payload() default {};
|
||||
|
||||
}
|
||||
|
@ -8,12 +8,14 @@ import org.baeldung.persistence.service.UserDto;
|
||||
public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, Object> {
|
||||
|
||||
@Override
|
||||
public void initialize(PasswordMatches constraintAnnotation) {
|
||||
public void initialize(final PasswordMatches constraintAnnotation) {
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object obj, ConstraintValidatorContext context) {
|
||||
UserDto user = (UserDto) obj;
|
||||
public boolean isValid(final Object obj, final ConstraintValidatorContext context) {
|
||||
final UserDto user = (UserDto) obj;
|
||||
return user.getPassword().equals(user.getMatchingPassword());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import org.springframework.validation.Validator;
|
||||
public class UserValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
public boolean supports(final Class<?> clazz) {
|
||||
return UserDto.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object obj, Errors errors) {
|
||||
public void validate(final Object obj, final Errors errors) {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "message.firstName", "Firstname is required.");
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "message.lastName", "LastName is required.");
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "message.password", "LastName is required.");
|
||||
|
@ -1,14 +1,16 @@
|
||||
package org.baeldung.validation;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
|
||||
@Target({ TYPE, FIELD, ANNOTATION_TYPE })
|
||||
@Retention(RUNTIME)
|
||||
|
@ -61,7 +61,7 @@ public class OldRegistrationController {
|
||||
private Environment env;
|
||||
|
||||
public OldRegistrationController() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
@ -61,7 +61,7 @@ public class RegistrationController {
|
||||
private Environment env;
|
||||
|
||||
public RegistrationController() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
// Registration
|
||||
|
@ -12,12 +12,12 @@ public class GenericResponse {
|
||||
private String message;
|
||||
private String error;
|
||||
|
||||
public GenericResponse(String message) {
|
||||
public GenericResponse(final String message) {
|
||||
super();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public GenericResponse(String message, String error) {
|
||||
public GenericResponse(final String message, final String error) {
|
||||
super();
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
@ -39,7 +39,7 @@ public class GenericResponse {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class GenericResponse {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
public void setError(final String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"
|
||||
>
|
||||
|
||||
</beans>
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -230,19 +230,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -263,7 +263,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -225,19 +225,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -258,7 +258,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -25,9 +25,10 @@
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -87,19 +87,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -119,7 +119,7 @@
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -222,19 +222,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -255,7 +255,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
@ -230,19 +230,19 @@
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.6.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.7.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.0.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.2.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.36</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.12</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
|
||||
<!-- various -->
|
||||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>18.0</guava.version>
|
||||
@ -263,7 +263,7 @@
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user