Introduction to Spring Data KeyValue
Spring Data KeyValue is an integral part of the larger Spring Data project, which aims to simplify the creation of Spring-based applications using contemporary data access technologies like non-relational databases, map-reduce frameworks, and cloud-based data services. This module focuses specifically on providing essential infrastructure components for building repository abstractions tailored for stores handling key/value pairs.
Features
Spring Data KeyValue offers a range of features that make it a powerful tool for developers:
- Infrastructure for Key/Value Repositories: It provides all the necessary components to easily construct repositories on top of key/value implementations.
- Dynamic SpEL Query Generation: Developers can dynamically generate queries from method names using Spring Expression Language (SpEL).
- Custom Repository Integration: There's flexibility for integrating custom repository code, allowing developers to extend functionality as required.
Code of Conduct
The project adheres to the Spring Code of Conduct, ensuring a respectful and collaborative environment. Any unacceptable behavior can be reported to the provided contact.
Getting Started
Here's an example of how one might set up a simple application using Spring Data KeyValue repositories in Java:
public interface PersonRepository extends CrudRepository<Person, Long> {
List<Person> findByLastname(String lastname);
List<Person> findByFirstnameLike(String firstname);
}
@Service
public class MyService {
private final PersonRepository repository;
public MyService(PersonRepository repository) {
this.repository = repository;
}
public void doWork() {
repository.deleteAll();
Person person = new Person();
person.setFirstname("Oliver");
person.setLastname("Gierke");
repository.save(person);
List<Person> lastNameResults = repository.findByLastname("Gierke");
List<Person> firstNameResults = repository.findByFirstnameLike("Oli*");
}
}
@KeySpace("person")
class Person {
@Id String uuid;
String firstname;
String lastname;
// getters and setters omitted for brevity
}
@Configuration
@EnableMapRepositories("com.acme.repositories")
class AppConfig { … }
Maven Configuration
To include Spring Data KeyValue in a Maven project, one must add the appropriate dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<version>${version}.RELEASE</version>
</dependency>
For those who prefer to stay ahead with the latest version, including snapshots, configuring the Maven snapshot repository and adjusting dependency versions is recommended.
Getting Help
Assistance is readily available for developers working with Spring Data through various channels:
- Detailed reference documentation and Javadocs.
- Engaging with the Spring community via platforms like stackoverflow.com and Gitter.
Reporting Issues
Handling of issues and feature requests is managed through GitHub:
- Prior to reporting, it's recommended to search for existing issues to avoid duplicates.
- Providing comprehensive detail on any new issue, including software version and stack traces, is encouraged.
- Where possible, submit a test case or sample project illustrating the issue.
Building from Source
For developers interested in the latest updates or custom modifications, building Spring Data from source is straightforward. With basic tools like the Maven Wrapper and JDK 17, the process can be initiated with:
$ ./mvnw clean install
Additional Resources
Explore example projects that showcase specific Spring Data KeyValue features at the Spring Data Examples repository.
License
Spring Data KeyValue is open-source software released under the Apache 2.0 license, reinforcing its commitment to free and collaborative software development.
This guide provides a comprehensive overview of Spring Data KeyValue, serving as a stepping stone for developers looking to integrate key/value pair management into their Spring applications efficiently.