b090041-lrsrcldinfoservice-client-spring
A client library for accessing http://apis.data.go.kr/B090041/openapi/service/LrsrCldInfoService.
See 음양력정보(data.go.kr) and/or 월별음약력(천문연구원).
Verify
Verify with your own service key assigned by the service provider.
$ mvn -Pfailsafe -DservcieKey=... clean verify
You may put your service key on src/test/resources/failsafe.system.properties
, which is git-ignored, like this,
serviceKey=...
and verify like this.
$ mvn -Pfailsafe clean verify
Injection points
Common
Qualifier | Type | Notes |
---|---|---|
@LrsrCldInfoServiceServiceKey |
java.lang.String |
Provided by the service provider |
For LrsrCldInfoServiceClient
with RestTemplate
Qualifier | Type | Notes |
---|---|---|
@LrsrCldInfoServiceRestTemplate |
RestTemplate |
|
@LrsrCldInfoServiceRestTemplateRootUri |
String |
Optional |
For LrsrCldInfoServiceReactiveClient
with WebClient
Qualifier | Type | Notes |
---|---|---|
@LrsrCldInfoServiceWebClient |
WebClient |
Usages
Expand the component-scanning path.
@SpringBootApplication(
scanBasePackageClasses = {
com.github.jinahya.datagokr.....client.NoOp.class,
MyApplication.class
}
)
class MyApplication {
}
Provide the service key assigned by the service provider. Note that the service provider may give you a URL-encoded value. You should use a URL-decoded value.
@AbstractLrsrCldInfoServiceClient.LrsrCldInfoServiceServiceKey
@Bean
public String lrsrCldInfoServiceServiceKey(){
// The service key assigned by data.go.kr
// Might be already URL-encoded
// Use a URL-decoded value
// return "...%3D%3D"; (X)
// return "...=="; (O)
}
Using LrsrCldInfoServiceClient
with RestTemplate
Provide an instance of RestTemplate
.
@LrsrCldInfoServiceRestTemplate
@Bean
public RestTemplate lrsrCldInfoServiceRestTemplate() {
return new RestTemplateBuilder()
...
.rootUri(AbstractLrsrCldInfoServiceClient.BASE_URL_PRODUCTION)
.build();
}
Get @Autowired
with an instance of LrsrCldInfoServiceClient
which is internally got autowired with the RestTemplate
instance.
@Autowired
private LrsrCldInfoServiceClient client;
Using LrsrCldInfoServiceReactiveClient
with WebClient
Provide an instance of WebClient
.
@LrsrCldInfoServiceWebClient
@Bean
public WebClient lrsrCldInfoServiceWebClient() {
return WebClient.builder()
...
.baseUrl(AbstractLrsrCldInfoServiceClient.BASE_URL_PRODUCTION)
.build();
}
Get @Autowired
with an instance of LrsrCldInfoServiceReactiveClient
which is internally got autowired with the WebClient
instance.
@Autowired
private LrsrCldInfoServiceReactiveClient client;