I am new to the spring-aerospike-data, I was hoping if someone could let me know how can I remove @user_key
and @_class
bins when I send post request to the application. I am trying to use spring-areospike-data in my Rest-api. please see bleow example:
- POM dependecis:
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>spring-data-aerospike</artifactId>
<version>3.0.0</version>
</dependency>
- Spring version: 2.5.1
- Configruation classes:
@Data
@Component
@ConfigurationProperties(prefix = "aerospike")
public class AerospikeConfigurationProperties {
private String host;
private int port;
private String namespace;
}
@Configuration
@EnableConfigurationProperties(AerospikeConfigurationProperties.class)
@EnableAerospikeRepositories(basePackages = "com.moneris.repositories")
public class AerospikeConfiguration extends AbstractAerospikeDataConfiguration {
@Autowired
private AerospikeConfigurationProperties aerospikeConfigurationProperties;
@Override
protected Collection<Host> getHosts() {
return Collections.singleton(new Host(aerospikeConfigurationProperties.getHost(),
aerospikeConfigurationProperties.getPort()));
}
@Override
protected String nameSpace() {
return aerospikeConfigurationProperties.getNamespace();
}
}
pom dependencies: here is my POJO:
@Data
@Document
@AllArgsConstructor
public class UserApi {
@Id
private String apiKey;
private String apiName;
private int enabled;
}
and here is the repo:
public interface AerospikeUserApiKeyRepository extends CrudRepository<UserApi, String> {
}
and here is service:
@Service
@AllArgsConstructor
public class UserService {
AerospikeUserApiKeyRepository aerospikeUserApiKeyRepository;
public void addUserApiKey(UserApi userApi) {
aerospikeUserApiKeyRepository.save(userApi);
}
public Optional<UserApi> getUserApi(String apiKey){
return aerospikeUserApiKeyRepository.findById(apiKey);
}
}
here the controller:
@RestController
@AllArgsConstructor
public class UserController {
UserService userService;
@PostMapping("/users/apiKey")
public void addUserApi(@RequestBody UserApi userApi) {
userService.addUserApiKey(userApi);;
}
@GetMapping("/users/apiKey/{apiKey}")
public Optional<UserApi> getUserApi(@PathVariable("apiKey") String apiKey) {
return userService.getUserApi(apiKey);
}
}
when I run my applicaiton and send post request to the http://localhost:8080/users/apiKey
with below json body
{
"apiKey": "ABC",
"apiName": "TEST",
"enabled": 1
}
I am geting below record in the aerospike db
is ther any way not stor
@user_key and @_class
in the sets?