spring-retrofit2

Spring manage retrofit service.

License

License

Categories

Categories

Retrofit Net HTTP Clients
GroupId

GroupId

com.github.blackshadowwalker.spring
ArtifactId

ArtifactId

spring-retrofit2
Last Version

Last Version

2.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

spring-retrofit2
Spring manage retrofit service.
Project URL

Project URL

https://github.com/blackshadowwalker/spring-retrofit2
Source Code Management

Source Code Management

https://github.com/blackshadowwalker/spring-retrofit2

Download spring-retrofit2

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 3.3.0
com.squareup.retrofit2 : retrofit jar 2.1.0
com.squareup.retrofit : retrofit jar 1.9.0
org.ligboy.retrofit2 : converter-fastjson jar 2.1.0
org.springframework : spring-context jar 4.2.5.RELEASE
org.slf4j : slf4j-api jar 1.7.18

test (8)

Group / Artifact Type Version
com.squareup.okhttp3 : mockwebserver jar 3.3.0
org.springframework : spring-test jar 4.2.5.RELEASE
junit : junit jar 4.10
com.google.guava : guava jar 19.0
ch.qos.logback : logback-classic jar 1.1.6
org.slf4j : jcl-over-slf4j jar 1.7.18
org.slf4j : jul-to-slf4j jar 1.7.18
org.slf4j : log4j-over-slf4j jar 1.7.18

Project Modules

There are no modules declared in this project.

spring-retrofit

Version

jdk

OKHttp3 Retrofit Spring

Usage

maven

<dependency>
    <groupId>com.github.blackshadowwalker.spring</groupId>
    <artifactId>spring-retrofit2</artifactId>
    <version>2.1.0</version>
</dependency>

Config

@Configuration
@EnableRetrofit
public class RetrofitConfig {

    @Bean
    public RetrofitServiceScannerConfigurer config(Retrofit retrofit) {
        RetrofitServiceScannerConfigurer configurer = new RetrofitServiceScannerConfigurer();
        configurer.setBasePackage(com.github.blackshadowwalker.spring.retrofit.serviceg.retrofit.service");
        configurer.setRetrofit(retrofit);
        return configurer;
    }

}

Define annotations at retrofit service

@RetrofitService
public interface MyRpcService {
    ...
}

Multi RPC Server

S1: Define Multi Retrofit

@Bean
public Retrofit retrofitDefault(OkHttpClient okHttpClient) {
    return new Retrofit.Builder()
            .baseUrl("http://127.0.0.1:8081")
            .addConverterFactory(FastJsonConverterFactory.create())
            .client(okHttpClient)
            .build();
}

@Bean
public Retrofit retrofit8082(OkHttpClient okHttpClient) {
    return new Retrofit.Builder()
            .baseUrl("http://127.0.0.1:8082")
            .addConverterFactory(FastJsonConverterFactory.create())
            .client(okHttpClient)
            .build();
}

S2: Define annotations at retrofit service

@RetrofitService(retrofit = "retrofit8082")
public interface MyRpcService {
    ...
}

More

More Detail see the testCase.

Versions

Version
2.1.1
2.1.0