com.github.wonwoo:dynamodb-spring-boot-test-autoconfigure

dynamodb Spring boot AutoConfigure

License

License

Categories

Categories

Spring Boot Container Microservices Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

com.github.wonwoo
ArtifactId

ArtifactId

dynamodb-spring-boot-test-autoconfigure
Last Version

Last Version

1.0.1-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

dynamodb Spring boot AutoConfigure

Download dynamodb-spring-boot-test-autoconfigure

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.wonwoo/dynamodb-spring-boot-test-autoconfigure/ -->
<dependency>
    <groupId>com.github.wonwoo</groupId>
    <artifactId>dynamodb-spring-boot-test-autoconfigure</artifactId>
    <version>1.0.1-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.wonwoo/dynamodb-spring-boot-test-autoconfigure/
implementation 'com.github.wonwoo:dynamodb-spring-boot-test-autoconfigure:1.0.1-RELEASE'
// https://jarcasting.com/artifacts/com.github.wonwoo/dynamodb-spring-boot-test-autoconfigure/
implementation ("com.github.wonwoo:dynamodb-spring-boot-test-autoconfigure:1.0.1-RELEASE")
'com.github.wonwoo:dynamodb-spring-boot-test-autoconfigure:jar:1.0.1-RELEASE'
<dependency org="com.github.wonwoo" name="dynamodb-spring-boot-test-autoconfigure" rev="1.0.1-RELEASE">
  <artifact name="dynamodb-spring-boot-test-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.wonwoo', module='dynamodb-spring-boot-test-autoconfigure', version='1.0.1-RELEASE')
)
libraryDependencies += "com.github.wonwoo" % "dynamodb-spring-boot-test-autoconfigure" % "1.0.1-RELEASE"
[com.github.wonwoo/dynamodb-spring-boot-test-autoconfigure "1.0.1-RELEASE"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-test-autoconfigure jar
org.springframework : spring-test jar
com.github.wonwoo : dynamodb-spring-boot-starter Optional jar 1.0.1-RELEASE

test (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar
com.amazonaws » DynamoDBLocal jar 1.11.86
com.almworks.sqlite4java : sqlite4java jar 1.0.392

Project Modules

There are no modules declared in this project.

dynamodb-spring-boot

Coverage Status Build Status Build Status Download Maven Central

spring boot version

dynamodb-spring-boot-starter version spring-data-dynamodb version Spring Boot version
0.1.2 4.5.x >= 1.4.0 < 2.0
1.0.x 5.0.x >= 2.0

dynamodb-spring-boot Example

  1. application.properties
spring.data.dynamodb.access-key=<your access-key>
spring.data.dynamodb.secret-key=<your secret-key>
  1. PersonRepository
@EnableScan
public interface PersonRepository extends DynamoDBRepository<Person, String> {
}
  1. Person
@DynamoDBTable(tableName = "persons")
public class Person {

    @DynamoDBHashKey
    @DynamoDBAutoGeneratedKey
    private String id;
    private String name;

    public Person() {

    }
    // getter setter etc
}
  1. Sample
@Bean
CommandLineRunner commandLineRunner(PersonRepository personRepository) {
    return args -> {
        personRepository.save(Arrays.asList(
                new Person("kevin"),
                new Person("josh long"))
        );
        personRepository.findAll()
                .forEach(System.out::println);
    };
}

Maven Install

<dependency>
    <groupId>com.github.wonwoo</groupId>
    <artifactId>dynamodb-spring-boot-starter</artifactId>
    <version>{version}-RELEASE</version>
</dependency>

Create DDL

spring.data.dynamodb.ddl.enabled=true

spring.data.dynamodb.ddl.enabled default by false

dynamodb-spring-boot-test Example

@DynamoTest

@DynamoTest
@RunWith(SpringRunner.class)
public class PersonRepositoryTests {

    @Autowired
    private PersonRepository personRepository;

    @Test
    public void save() {
        List<Person> persons = personRepository.findAll();
        assertThat(persons).hasSize(2);
    }
}

Maven Install

<dependency>
  <groupId>com.github.wonwoo</groupId>
  <artifactId>dynamodb-spring-boot-starter-test</artifactId>
  <version>{version}-RELEASE</version>
  <scope>test</scope>
</dependency>

Embedded Dynamodb setting

  1. maven dependency
<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>DynamoDBLocal</artifactId>
  <version>{local.version}</version>  
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>com.almworks.sqlite4java</groupId>
  <artifactId>sqlite4java</artifactId>
  <version>{local.version}</version>  
  <scope>test</scope>
</dependency>
  1. maven plugins
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>process-test-resources</phase>
        <goals>
          <goal>copy-dependencies</goal>
        </goals>
        <configuration>
          <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
          <overWriteReleases>false</overWriteReleases>
          <overWriteSnapshots>false</overWriteSnapshots>
          <overWriteIfNewer>true</overWriteIfNewer>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <configuration>
      <argLine>-Dsqlite4java.library.path=${basedir}/target/dependencies</argLine>
    </configuration>
  </plugin>
</plugins>

Sample code github

Sample

SampleApplication

PersonRepositoryTests

Read more here

Versions

Version
1.0.1-RELEASE
0.1.2-RELEASE
0.1.0-RELEASE