From b02d83df2242da8b85d2451d81f1c75dffe0672a Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sat, 17 Sep 2016 22:51:06 -0700 Subject: [PATCH 01/13] BAEL-223 - Integrate DynamoDB into a Spring Boot Application using Spring Data --- spring-boot-data-dynamodb/.gitignore | 4 + spring-boot-data-dynamodb/README.MD | 2 + spring-boot-data-dynamodb/pom.xml | 189 ++++++++++++++++++ .../spring/data/es/config/DynamoDBConfig.java | 41 ++++ .../spring/data/es/model/ProductInfo.java | 47 +++++ .../es/repository/ProductInfoRepository.java | 14 ++ .../main/java/org/baeldung/Application.java | 13 ++ .../src/main/resources/application.properties | 31 +++ .../src/main/resources/demo.properties | 6 + .../src/main/resources/logback.xml | 14 ++ .../src/main/resources/templates/index.html | 19 ++ .../ProductInfoRepositoryIntegrationTest.java | 85 ++++++++ .../src/test/resources/application.properties | 7 + .../resources/exception-hibernate.properties | 2 + .../src/test/resources/exception.properties | 6 + 15 files changed, 480 insertions(+) create mode 100644 spring-boot-data-dynamodb/.gitignore create mode 100644 spring-boot-data-dynamodb/README.MD create mode 100644 spring-boot-data-dynamodb/pom.xml create mode 100644 spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java create mode 100644 spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java create mode 100644 spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java create mode 100644 spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java create mode 100644 spring-boot-data-dynamodb/src/main/resources/application.properties create mode 100644 spring-boot-data-dynamodb/src/main/resources/demo.properties create mode 100644 spring-boot-data-dynamodb/src/main/resources/logback.xml create mode 100644 spring-boot-data-dynamodb/src/main/resources/templates/index.html create mode 100644 spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java create mode 100644 spring-boot-data-dynamodb/src/test/resources/application.properties create mode 100644 spring-boot-data-dynamodb/src/test/resources/exception-hibernate.properties create mode 100644 spring-boot-data-dynamodb/src/test/resources/exception.properties diff --git a/spring-boot-data-dynamodb/.gitignore b/spring-boot-data-dynamodb/.gitignore new file mode 100644 index 0000000000..e26d6af438 --- /dev/null +++ b/spring-boot-data-dynamodb/.gitignore @@ -0,0 +1,4 @@ +/target/ +.settings/ +.classpath +.project diff --git a/spring-boot-data-dynamodb/README.MD b/spring-boot-data-dynamodb/README.MD new file mode 100644 index 0000000000..2a87b46021 --- /dev/null +++ b/spring-boot-data-dynamodb/README.MD @@ -0,0 +1,2 @@ +###The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/spring-boot-data-dynamodb/pom.xml b/spring-boot-data-dynamodb/pom.xml new file mode 100644 index 0000000000..023d249c56 --- /dev/null +++ b/spring-boot-data-dynamodb/pom.xml @@ -0,0 +1,189 @@ + + 4.0.0 + com.baeldung + spring-boot + 0.0.1-SNAPSHOT + jar + Spring Boot Actuator + This is simple boot application for Spring boot actuator test + + + spring-boot-starter-parent + org.springframework.boot + 1.2.3.RELEASE + + + + + + org.baeldung.boot.DemoApplication + UTF-8 + 1.8 + 4.3.1.RELEASE + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter-security + + + + io.dropwizard.metrics + metrics-core + + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-starter + + + com.jayway.jsonpath + json-path + test + + + org.springframework.boot + spring-boot-starter-mail + + + org.subethamail + subethasmtp + 3.1.7 + test + + + + org.webjars + bootstrap + 3.3.4 + + + org.webjars + jquery + 2.1.4 + + + org.springframework.data + spring-data-jpa + 1.10.2.RELEASE + + + com.amazonaws + aws-java-sdk-dynamodb + 1.11.34 + + + org.socialsignin + spring-data-dynamodb + 4.2.1 + + + + + spring-boot + + + src/main/resources + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-war-plugin + + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + opensourceagility-release + http://repo.opensourceagility.com/release/ + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java new file mode 100644 index 0000000000..554a6c9c12 --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -0,0 +1,41 @@ +package com.baeldung.spring.data.es.config; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; +import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; + +@Configuration +@ComponentScan(basePackages = { "com.baeldung.spring.data.es.service" }) +public class DynamoDBConfig { + + @Value("${amazon.dynamodb.endpoint}") + private String amazonDynamoDBEndpoint; + + @Value("${amazon.aws.accesskey}") + private String amazonAWSAccessKey; + + @Value("${amazon.aws.secretkey}") + private String amazonAWSSecretKey; + + @Bean + public AmazonDynamoDB amazonDynamoDB() { + AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials()); + if (StringUtils.isNotEmpty(amazonDynamoDBEndpoint)) { + amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint); + } + return amazonDynamoDB; + } + + @Bean + public AWSCredentials amazonAWSCredentials() { + return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey); + } + +} diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java new file mode 100644 index 0000000000..4c97d14045 --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java @@ -0,0 +1,47 @@ +package com.baeldung.spring.data.es.model; + +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; + +public class ProductInfo { + private String id; + private String msrp; + private String cost; + + public ProductInfo() { + } + + public ProductInfo(String cost, String msrp) { + this.msrp = msrp; + this.cost = cost; + } + + @DynamoDBHashKey + @DynamoDBAutoGeneratedKey + public String getId() { + return id; + } + + @DynamoDBAttribute + public String getMsrp() { + return msrp; + } + + @DynamoDBAttribute + public String getCost() { + return cost; + } + + public void setId(String id) { + this.id = id; + } + + public void setMsrp(String msrp) { + this.msrp = msrp; + } + + public void setCost(String cost) { + this.cost = cost; + } +} diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java new file mode 100644 index 0000000000..a30ff1c4aa --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java @@ -0,0 +1,14 @@ +package com.baeldung.spring.data.es.repository; + +import java.util.List; + +import org.socialsignin.spring.data.dynamodb.repository.EnableScan; +import org.springframework.data.repository.CrudRepository; + +import com.baeldung.spring.data.es.model.ProductInfo; + +@EnableScan +public interface ProductInfoRepository extends CrudRepository { + + List findById(String id); +} diff --git a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java new file mode 100644 index 0000000000..aae0c427a9 --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java @@ -0,0 +1,13 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.context.ApplicationContext; + +@org.springframework.boot.autoconfigure.SpringBootApplication +public class Application { + private static ApplicationContext applicationContext; + + public static void main(String[] args) { + applicationContext = SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-data-dynamodb/src/main/resources/application.properties b/spring-boot-data-dynamodb/src/main/resources/application.properties new file mode 100644 index 0000000000..d30045d1dc --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/resources/application.properties @@ -0,0 +1,31 @@ +server.port=8080 +server.contextPath=/springbootapp +management.port=8081 +management.address=127.0.0.1 + +endpoints.shutdown.enabled=true + +endpoints.jmx.domain=Spring Sample Application +endpoints.jmx.uniqueNames=true + +##jolokia.config.debug=true +##endpoints.jolokia.enabled=true +##endpoints.jolokia.path=jolokia + +spring.jmx.enabled=true +endpoints.jmx.enabled=true + +## for pretty printing of json when endpoints accessed over HTTP +http.mappers.jsonPrettyPrint=true + +## Configuring info endpoint +info.app.name=Spring Sample Application +info.app.description=This is my first spring boot application G1 +info.app.version=1.0.0 + +## Spring Security Configurations +security.user.name=admin1 +security.user.password=secret1 +management.security.role=SUPERUSER + +logging.level.org.springframework=INFO \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/main/resources/demo.properties b/spring-boot-data-dynamodb/src/main/resources/demo.properties new file mode 100644 index 0000000000..649b64f59b --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/resources/demo.properties @@ -0,0 +1,6 @@ +spring.output.ansi.enabled=never +server.port=7070 + +# Security +security.user.name=admin +security.user.password=password \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/main/resources/logback.xml b/spring-boot-data-dynamodb/src/main/resources/logback.xml new file mode 100644 index 0000000000..78913ee76f --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/resources/logback.xml @@ -0,0 +1,14 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/main/resources/templates/index.html b/spring-boot-data-dynamodb/src/main/resources/templates/index.html new file mode 100644 index 0000000000..046d21600a --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/resources/templates/index.html @@ -0,0 +1,19 @@ + + + WebJars Demo + + + + +

+
+ × + Success! It is working as we expected. +
+
+ + + + + + \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java new file mode 100644 index 0000000000..438499bae8 --- /dev/null +++ b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.spring.data.es.repository; + +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.baeldung.Application; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.IntegrationTest; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; +import com.amazonaws.services.dynamodbv2.document.DynamoDB; +import com.amazonaws.services.dynamodbv2.document.Table; +import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; +import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; +import com.amazonaws.services.dynamodbv2.model.ResourceInUseException; +import com.baeldung.spring.data.es.model.ProductInfo; +import com.baeldung.spring.data.es.repository.ProductInfoRepository; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = Application.class) +@WebAppConfiguration +@IntegrationTest +@ActiveProfiles("local") +@TestPropertySource(properties = { "amazon.dynamodb.endpoint=http://localhost:8000/", "amazon.aws.accesskey=test1", "amazon.aws.secretkey=test231" }) +public class ProductInfoRepositoryIntegrationTest { + + private DynamoDBMapper dynamoDBMapper; + + @Autowired + private DynamoDB dynamoDB; + + @Autowired + private AmazonDynamoDB amazonDynamoDB; + + @Autowired + ProductInfoRepository ProductInfoRepository; + + private static final String EXPECTED_COST = "20"; + private static final String EXPECTED_PRICE = "50"; + + @Before + @Ignore + public void setUp() throws Exception { + + try { + dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB); + + CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(ProductInfo.class); // 1 + + tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L)); // 2 + + Table table = dynamoDB.createTable(tableRequest); // 3 + + table.waitForActive(); // 4 + } catch (ResourceInUseException e) { + // Do nothing, table already created + } + + // TODO How to handle different environments. i.e. AVOID deleting all entries in ProductInfoion table + dynamoDBMapper.batchDelete((List) ProductInfoRepository.findAll()); + } + + @Ignore + @Test + public void sampleTestCase() { + + ProductInfo dave = new ProductInfo(EXPECTED_COST, EXPECTED_PRICE); + ProductInfoRepository.save(dave); + + List result = (List) ProductInfoRepository.findAll(); + assertTrue("Not empty", result.size() > 0); + assertTrue("Contains item with expected cost", result.get(0).getCost().equals(EXPECTED_COST)); + } +} diff --git a/spring-boot-data-dynamodb/src/test/resources/application.properties b/spring-boot-data-dynamodb/src/test/resources/application.properties new file mode 100644 index 0000000000..01e8a2e52e --- /dev/null +++ b/spring-boot-data-dynamodb/src/test/resources/application.properties @@ -0,0 +1,7 @@ +spring.mail.host=localhost +spring.mail.port=8025 +spring.mail.properties.mail.smtp.auth=false + +amazon.dynamodb.endpoint=http://localhost:8000/ +amazon.aws.accesskey=key +amazon.aws.secretkey=key2 \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/test/resources/exception-hibernate.properties b/spring-boot-data-dynamodb/src/test/resources/exception-hibernate.properties new file mode 100644 index 0000000000..cde746acb9 --- /dev/null +++ b/spring-boot-data-dynamodb/src/test/resources/exception-hibernate.properties @@ -0,0 +1,2 @@ +spring.profiles.active=exception +spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext diff --git a/spring-boot-data-dynamodb/src/test/resources/exception.properties b/spring-boot-data-dynamodb/src/test/resources/exception.properties new file mode 100644 index 0000000000..c55e415a3a --- /dev/null +++ b/spring-boot-data-dynamodb/src/test/resources/exception.properties @@ -0,0 +1,6 @@ +# Security +security.user.name=admin +security.user.password=password + +spring.dao.exceptiontranslation.enabled=false +spring.profiles.active=exception \ No newline at end of file From d48bf9d2b6e122e21caf1e965a5bfb374757b50f Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sat, 17 Sep 2016 23:15:17 -0700 Subject: [PATCH 02/13] BAEL-223 - Update Unit test name --- .../repository/ProductInfoRepositoryIntegrationTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java index 438499bae8..43369d3254 100644 --- a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java +++ b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java @@ -25,7 +25,6 @@ import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; import com.amazonaws.services.dynamodbv2.model.ResourceInUseException; import com.baeldung.spring.data.es.model.ProductInfo; -import com.baeldung.spring.data.es.repository.ProductInfoRepository; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @@ -73,10 +72,10 @@ public class ProductInfoRepositoryIntegrationTest { @Ignore @Test - public void sampleTestCase() { + public void givenItemWithExpectedCost_whenRunFindAll_thenItemIsFound() { - ProductInfo dave = new ProductInfo(EXPECTED_COST, EXPECTED_PRICE); - ProductInfoRepository.save(dave); + ProductInfo productInfo = new ProductInfo(EXPECTED_COST, EXPECTED_PRICE); + ProductInfoRepository.save(productInfo); List result = (List) ProductInfoRepository.findAll(); assertTrue("Not empty", result.size() > 0); From a0f281a9f7f8e7657ee6cadaec78c7e9db71437c Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sun, 2 Oct 2016 18:44:56 -0700 Subject: [PATCH 03/13] Updated dependencies to use newer version of dynamoDB dependency --- spring-boot-data-dynamodb/pom.xml | 8 ++------ .../baeldung/spring/data/es/config/DynamoDBConfig.java | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/spring-boot-data-dynamodb/pom.xml b/spring-boot-data-dynamodb/pom.xml index 023d249c56..9c6c5a875f 100644 --- a/spring-boot-data-dynamodb/pom.xml +++ b/spring-boot-data-dynamodb/pom.xml @@ -105,9 +105,9 @@ 1.11.34 - org.socialsignin + com.github.derjust spring-data-dynamodb - 4.2.1 + 4.3.1 @@ -162,10 +162,6 @@ false - - opensourceagility-release - http://repo.opensourceagility.com/release/ - diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java index 554a6c9c12..984262a949 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -1,10 +1,12 @@ package com.baeldung.spring.data.es.config; -import org.apache.commons.lang3.StringUtils; + + import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.util.StringUtils; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; @@ -27,7 +29,7 @@ public class DynamoDBConfig { @Bean public AmazonDynamoDB amazonDynamoDB() { AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials()); - if (StringUtils.isNotEmpty(amazonDynamoDBEndpoint)) { + if (StringUtils.isEmpty(amazonDynamoDBEndpoint)) { amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint); } return amazonDynamoDB; From 7c7d91fe7b9d752553bf8b464faa5f32f137b411 Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sun, 2 Oct 2016 18:47:31 -0700 Subject: [PATCH 04/13] Use provided auto-formater --- .../java/com/baeldung/spring/data/es/config/DynamoDBConfig.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java index 984262a949..5ced393fd4 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -1,7 +1,5 @@ package com.baeldung.spring.data.es.config; - - import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; From d478746229bbfafd494b84de915315ff0088fc3a Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sun, 2 Oct 2016 19:08:03 -0700 Subject: [PATCH 05/13] Updated component scan path --- .../java/com/baeldung/spring/data/es/config/DynamoDBConfig.java | 2 +- .../src/main/java/org/baeldung/Application.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java index 5ced393fd4..b215e357d9 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -12,7 +12,7 @@ import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; @Configuration -@ComponentScan(basePackages = { "com.baeldung.spring.data.es.service" }) +@ComponentScan(basePackages = { "com.baeldung.spring.data.es" }) public class DynamoDBConfig { @Value("${amazon.dynamodb.endpoint}") diff --git a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java index aae0c427a9..76895ca575 100644 --- a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java +++ b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java @@ -10,4 +10,4 @@ public class Application { public static void main(String[] args) { applicationContext = SpringApplication.run(Application.class, args); } -} +} \ No newline at end of file From 2693991c1b60b86eb933cf1c1eef76938c823a65 Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Sun, 2 Oct 2016 19:10:55 -0700 Subject: [PATCH 06/13] Fixed missing new line issue --- .../src/main/java/org/baeldung/Application.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java index 76895ca575..aae0c427a9 100644 --- a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java +++ b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java @@ -10,4 +10,4 @@ public class Application { public static void main(String[] args) { applicationContext = SpringApplication.run(Application.class, args); } -} \ No newline at end of file +} From e95d1e2908e2a2f2917a2e0042f4f0e45b770e75 Mon Sep 17 00:00:00 2001 From: Chris Anatalio Date: Thu, 13 Oct 2016 07:54:58 -0700 Subject: [PATCH 07/13] @BeforeClass annotation and made setUp() method static --- .../es/repository/ProductInfoRepositoryIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java index 43369d3254..2421505acd 100644 --- a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java +++ b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java @@ -48,9 +48,9 @@ public class ProductInfoRepositoryIntegrationTest { private static final String EXPECTED_COST = "20"; private static final String EXPECTED_PRICE = "50"; - @Before + @BeforeClass @Ignore - public void setUp() throws Exception { + public static void setUp() throws Exception { try { dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB); From 427b012ee4707f4ce38b56abaa034ffe841b8e92 Mon Sep 17 00:00:00 2001 From: Chris Anatalio Date: Thu, 13 Oct 2016 07:59:24 -0700 Subject: [PATCH 08/13] Checking amazonDynamoDBEndpoint string is not empty --- .../java/com/baeldung/spring/data/es/config/DynamoDBConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java index b215e357d9..f98292ea06 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -27,7 +27,7 @@ public class DynamoDBConfig { @Bean public AmazonDynamoDB amazonDynamoDB() { AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials()); - if (StringUtils.isEmpty(amazonDynamoDBEndpoint)) { + if (!StringUtils.isEmpty(amazonDynamoDBEndpoint)) { amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint); } return amazonDynamoDB; From 7b6418e84c3fcb7ef50736153869c16bc1f4cc68 Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Thu, 13 Oct 2016 23:12:20 -0700 Subject: [PATCH 09/13] Cleaned up readme and application properties --- spring-boot-data-dynamodb/README.MD | 3 +-- .../src/main/resources/application.properties | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-boot-data-dynamodb/README.MD b/spring-boot-data-dynamodb/README.MD index 2a87b46021..8b13789179 100644 --- a/spring-boot-data-dynamodb/README.MD +++ b/spring-boot-data-dynamodb/README.MD @@ -1,2 +1 @@ -###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring + diff --git a/spring-boot-data-dynamodb/src/main/resources/application.properties b/spring-boot-data-dynamodb/src/main/resources/application.properties index d30045d1dc..fb5c8e2da0 100644 --- a/spring-boot-data-dynamodb/src/main/resources/application.properties +++ b/spring-boot-data-dynamodb/src/main/resources/application.properties @@ -8,10 +8,6 @@ endpoints.shutdown.enabled=true endpoints.jmx.domain=Spring Sample Application endpoints.jmx.uniqueNames=true -##jolokia.config.debug=true -##endpoints.jolokia.enabled=true -##endpoints.jolokia.path=jolokia - spring.jmx.enabled=true endpoints.jmx.enabled=true From a55b725cd322ba7d3e8fc705924b966628792649 Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Thu, 13 Oct 2016 23:18:01 -0700 Subject: [PATCH 10/13] Removed *'s added to illustrate spacing --- spring-boot-data-dynamodb/src/main/resources/logback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-data-dynamodb/src/main/resources/logback.xml b/spring-boot-data-dynamodb/src/main/resources/logback.xml index 78913ee76f..f10048e5d2 100644 --- a/spring-boot-data-dynamodb/src/main/resources/logback.xml +++ b/spring-boot-data-dynamodb/src/main/resources/logback.xml @@ -1,6 +1,6 @@ - + web - %date [%thread] %-5level %logger{36} - %message%n From c1444e2cdd7a69e35b7518ecc2148ed5596c2020 Mon Sep 17 00:00:00 2001 From: "chris.anatalio" Date: Thu, 13 Oct 2016 23:20:34 -0700 Subject: [PATCH 11/13] Fix new line issue --- spring-boot-data-dynamodb/src/main/resources/logback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-data-dynamodb/src/main/resources/logback.xml b/spring-boot-data-dynamodb/src/main/resources/logback.xml index f10048e5d2..c0bc602910 100644 --- a/spring-boot-data-dynamodb/src/main/resources/logback.xml +++ b/spring-boot-data-dynamodb/src/main/resources/logback.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + From 9aef7f21ece55732e512175a3e562698e8aa1ea5 Mon Sep 17 00:00:00 2001 From: Chris Anatalio Date: Fri, 21 Oct 2016 16:32:58 -0700 Subject: [PATCH 12/13] BAEL-223: Clean up and update dependencies --- spring-boot-data-dynamodb/pom.xml | 54 ++++++++---------- .../main/java/com/baeldung/Application.java | 13 +++++ .../spring/data/es/config/DynamoDBConfig.java | 13 ++--- .../spring/data/es/model/ProductInfo.java | 2 + .../ProductInfoRepository.java | 8 +-- .../main/java/org/baeldung/Application.java | 13 ----- .../src/main/resources/application.properties | 7 ++- .../ProductInfoRepositoryIntegrationTest.java | 55 +++++++++---------- 8 files changed, 78 insertions(+), 87 deletions(-) create mode 100644 spring-boot-data-dynamodb/src/main/java/com/baeldung/Application.java rename spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/{repository => repositories}/ProductInfoRepository.java (87%) delete mode 100644 spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java diff --git a/spring-boot-data-dynamodb/pom.xml b/spring-boot-data-dynamodb/pom.xml index 9c6c5a875f..11e1366f3e 100644 --- a/spring-boot-data-dynamodb/pom.xml +++ b/spring-boot-data-dynamodb/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung - spring-boot + spring-boot-dynamodb 0.0.1-SNAPSHOT jar Spring Boot Actuator @@ -17,27 +17,29 @@ - org.baeldung.boot.DemoApplication + com.baeldung.Application UTF-8 1.8 4.3.1.RELEASE - - - org.springframework.boot - spring-boot-starter-thymeleaf - + + + + org.springframework.data + spring-data-releasetrain + Gosling-SR1 + pom + import + + + + + org.springframework.boot spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - org.springframework.boot spring-boot-starter-actuator @@ -77,28 +79,13 @@ org.springframework.boot spring-boot-starter-mail - - org.subethamail - subethasmtp - 3.1.7 - test - - + org.webjars bootstrap 3.3.4 - - org.webjars - jquery - 2.1.4 - - - org.springframework.data - spring-data-jpa - 1.10.2.RELEASE - + com.amazonaws aws-java-sdk-dynamodb @@ -108,7 +95,12 @@ com.github.derjust spring-data-dynamodb 4.3.1 - + + + org.apache.httpcomponents + httpclient + 4.5.2 + diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/Application.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..f5e0e98fd4 --- /dev/null +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/Application.java @@ -0,0 +1,13 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "com.baeldung" }) +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java index f98292ea06..4bc8a128bc 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/config/DynamoDBConfig.java @@ -1,18 +1,17 @@ package com.baeldung.spring.data.es.config; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.StringUtils; - import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; +import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.StringUtils; @Configuration -@ComponentScan(basePackages = { "com.baeldung.spring.data.es" }) +@EnableDynamoDBRepositories(basePackages = "com.baeldung.spring.data.es.repositories") public class DynamoDBConfig { @Value("${amazon.dynamodb.endpoint}") diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java index 4c97d14045..3e75c9e6f2 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/model/ProductInfo.java @@ -3,7 +3,9 @@ package com.baeldung.spring.data.es.model; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; +@DynamoDBTable(tableName = "ProductInfo") public class ProductInfo { private String id; private String msrp; diff --git a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repositories/ProductInfoRepository.java similarity index 87% rename from spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java rename to spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repositories/ProductInfoRepository.java index a30ff1c4aa..c5eee49634 100644 --- a/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repository/ProductInfoRepository.java +++ b/spring-boot-data-dynamodb/src/main/java/com/baeldung/spring/data/es/repositories/ProductInfoRepository.java @@ -1,14 +1,12 @@ -package com.baeldung.spring.data.es.repository; - -import java.util.List; +package com.baeldung.spring.data.es.repositories; +import com.baeldung.spring.data.es.model.ProductInfo; import org.socialsignin.spring.data.dynamodb.repository.EnableScan; import org.springframework.data.repository.CrudRepository; -import com.baeldung.spring.data.es.model.ProductInfo; +import java.util.List; @EnableScan public interface ProductInfoRepository extends CrudRepository { - List findById(String id); } diff --git a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java b/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java deleted file mode 100644 index aae0c427a9..0000000000 --- a/spring-boot-data-dynamodb/src/main/java/org/baeldung/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung; - -import org.springframework.boot.SpringApplication; -import org.springframework.context.ApplicationContext; - -@org.springframework.boot.autoconfigure.SpringBootApplication -public class Application { - private static ApplicationContext applicationContext; - - public static void main(String[] args) { - applicationContext = SpringApplication.run(Application.class, args); - } -} diff --git a/spring-boot-data-dynamodb/src/main/resources/application.properties b/spring-boot-data-dynamodb/src/main/resources/application.properties index fb5c8e2da0..e6911bc9e7 100644 --- a/spring-boot-data-dynamodb/src/main/resources/application.properties +++ b/spring-boot-data-dynamodb/src/main/resources/application.properties @@ -24,4 +24,9 @@ security.user.name=admin1 security.user.password=secret1 management.security.role=SUPERUSER -logging.level.org.springframework=INFO \ No newline at end of file +logging.level.org.springframework=INFO + +#AWS Keys +amazon.dynamodb.endpoint=http://localhost:8000/ +amazon.aws.accesskey=test1 +amazon.aws.secretkey=test1 \ No newline at end of file diff --git a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java index 2421505acd..73ce60e79a 100644 --- a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java +++ b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java @@ -1,15 +1,22 @@ package com.baeldung.spring.data.es.repository; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.baeldung.Application; +import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; +import com.amazonaws.services.dynamodbv2.document.Table; +import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; +import com.amazonaws.services.dynamodbv2.model.CreateTableResult; +import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; +import com.amazonaws.services.dynamodbv2.model.ResourceInUseException; +import com.baeldung.Application; +import com.baeldung.spring.data.es.config.DynamoDBConfig; +import com.baeldung.spring.data.es.model.ProductInfo; +import com.baeldung.spring.data.es.repositories.ProductInfoRepository; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.ActiveProfiles; @@ -17,17 +24,12 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; -import com.amazonaws.services.dynamodbv2.document.DynamoDB; -import com.amazonaws.services.dynamodbv2.document.Table; -import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; -import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; -import com.amazonaws.services.dynamodbv2.model.ResourceInUseException; -import com.baeldung.spring.data.es.model.ProductInfo; +import java.util.List; + +import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = Application.class) +@SpringApplicationConfiguration(classes = {Application.class, DynamoDBConfig.class, PropertyPlaceholderAutoConfiguration.class}) @WebAppConfiguration @IntegrationTest @ActiveProfiles("local") @@ -36,48 +38,41 @@ public class ProductInfoRepositoryIntegrationTest { private DynamoDBMapper dynamoDBMapper; - @Autowired - private DynamoDB dynamoDB; - @Autowired private AmazonDynamoDB amazonDynamoDB; @Autowired - ProductInfoRepository ProductInfoRepository; + ProductInfoRepository repository; private static final String EXPECTED_COST = "20"; private static final String EXPECTED_PRICE = "50"; - @BeforeClass - @Ignore - public static void setUp() throws Exception { + @Before + public void setup() throws Exception { try { dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB); - CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(ProductInfo.class); // 1 + CreateTableRequest tableRequest = dynamoDBMapper.generateCreateTableRequest(ProductInfo.class); - tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L)); // 2 + tableRequest.setProvisionedThroughput(new ProvisionedThroughput(1L, 1L)); - Table table = dynamoDB.createTable(tableRequest); // 3 - - table.waitForActive(); // 4 + amazonDynamoDB.createTable(tableRequest); } catch (ResourceInUseException e) { // Do nothing, table already created } // TODO How to handle different environments. i.e. AVOID deleting all entries in ProductInfoion table - dynamoDBMapper.batchDelete((List) ProductInfoRepository.findAll()); + dynamoDBMapper.batchDelete((List) repository.findAll()); } - @Ignore @Test public void givenItemWithExpectedCost_whenRunFindAll_thenItemIsFound() { ProductInfo productInfo = new ProductInfo(EXPECTED_COST, EXPECTED_PRICE); - ProductInfoRepository.save(productInfo); + repository.save(productInfo); - List result = (List) ProductInfoRepository.findAll(); + List result = (List) repository.findAll(); assertTrue("Not empty", result.size() > 0); assertTrue("Contains item with expected cost", result.get(0).getCost().equals(EXPECTED_COST)); } From 5444f7c1dfa26336ef68a5e1fa3a56bc7a165166 Mon Sep 17 00:00:00 2001 From: Chris Anatalio Date: Fri, 21 Oct 2016 16:48:16 -0700 Subject: [PATCH 13/13] BAEL-223: Clean up imports and annotations --- .../repository/ProductInfoRepositoryIntegrationTest.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java index 73ce60e79a..df727cf727 100644 --- a/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java +++ b/spring-boot-data-dynamodb/src/test/java/com/baeldung/spring/data/es/repository/ProductInfoRepositoryIntegrationTest.java @@ -2,21 +2,16 @@ package com.baeldung.spring.data.es.repository; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; -import com.amazonaws.services.dynamodbv2.document.Table; import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; -import com.amazonaws.services.dynamodbv2.model.CreateTableResult; import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; import com.amazonaws.services.dynamodbv2.model.ResourceInUseException; import com.baeldung.Application; -import com.baeldung.spring.data.es.config.DynamoDBConfig; import com.baeldung.spring.data.es.model.ProductInfo; import com.baeldung.spring.data.es.repositories.ProductInfoRepository; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.ActiveProfiles; @@ -29,7 +24,7 @@ import java.util.List; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@SpringApplicationConfiguration(classes = {Application.class, DynamoDBConfig.class, PropertyPlaceholderAutoConfiguration.class}) +@SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration @IntegrationTest @ActiveProfiles("local")