Skip to content

jinahya/datagokr-api-b090041-lunphinfoservice-client-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

b090041-lunphdinfoservice-client-spring

Java CI with Maven Quality Gate Status Maven Central javadoc

A client library for accessing http://apis.data.go.kr/B090041/openapi/service/LunPhInfoService.

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 .gitignored, like this,

serviceKey=...

and verify like this.

$ mvn -Pfailsafe clean verify

Injection points

Common

Qualifier Type Notes
@LunPhInfoServiceServiceKey java.lang.String Provided by the service provider

For LunPhInfoServiceClient with RestTemplate

Qualifier Type Notes
@LunPhInfoServiceRestTemplate RestTemplate
@LunPhInfoServiceRestTemplateRootUri String Optional

For LunPhInfoServiceReactiveClient with WebClient

Qualifier Type Notes
@LunPhInfoServiceWebClient 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.

@AbstractLunPhInfoServiceClient.LunPhInfoServiceServiceKey
@Bean
public String lunPhInfoServiceServiceKey(){
    // 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 LunPhInfoServiceClient with RestTemplate

Provide an instance of RestTemplate.

@LunPhInfoServiceRestTemplate
@Bean
public RestTemplate lunPhInfoServiceRestTemplate() {
    return new RestTemplateBuilder()
            ...
            .rootUri(AbstractLunPhInfoServiceClient.BASE_URL_PRODUCTION)
            .build();
}

Get @Autowired with an instance of LunPhInfoServiceClient which is internally got autowired with the RestTemplate instance.

@Autowired
private LunPhInfoServiceClient client;

Using LunPhInfoServiceReactiveClient with WebClient

Provide an instance of WebClient.

@LunPhInfoServiceWebClient
@Bean
public WebClient lunPhInfoServiceWebClient() {
    return WebClient.builder()
            ...
            .baseUrl(AbstractLunPhInfoServiceClient.BASE_URL_PRODUCTION)
            .build();
}

Get @Autowired with an instance of LunPhInfoServiceReactiveClient which is internally got autowired with the WebClient instance.

@Autowired
private LunPhInfoServiceReactiveClient client;