Skip to content
프로젝트

LianjiaTech/retrofit-spring-boot-starter

GitHub에서 보기

소개

Retrofit용 Spring Boot 스타터로, 빠른 통합과 기능 확장을 지원합니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
-1

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

docs/ko/README.md

Original

retrofit-spring-boot-starter

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Español | Türkçe | Русский

License Maven Central License License

retrofit은 HTTP API를 Java 인터페이스로 변환하는 라이브러리입니다. 이 컴포넌트는 Retrofit과 SpringBoot를 깊이 통합하고, 여러 가지 실용적인 기능 향상을 지원합니다.

  • Spring Boot 3.x/4.x 프로젝트는 retrofit-spring-boot-starter 4.x를 사용하세요
    • Spring Boot 4.x는 기본적으로 jackson3을 사용하지만, 이 컴포넌트의 기본 converter는 jackson2입니다. Spring Boot 4.x 프로젝트에서는 글로벌 converter를 jackson3으로 설정하는 것을 권장합니다
    • 설정 방법: retrofit.global-converter-factories=com.github.lianjiatech.retrofit.spring.boot.core.jackson3.Jackson3ConverterFactory
  • Spring Boot 1.x/2.x 프로젝트는 retrofit-spring-boot-starter 2.x를 사용하세요. Spring Boot 1.4.2 이상 버전을 지원합니다.

빠른 시작

의존성 추가

<dependency>
    <groupId>com.github.lianjiatech</groupId>
    <artifactId>retrofit-spring-boot-starter</artifactId>
    <version>4.2.1</version>
</dependency>

대부분의 Spring Boot 프로젝트에서는 의존성을 추가하면 사용할 수 있습니다.

HTTP Java 인터페이스 정의

인터페이스에 @RetrofitClient 어노테이션을 반드시 표시해야 합니다!

@RetrofitClient(baseUrl = "http://localhost:8080/api/user/")
public interface UserService {

   /**
    * ID로 사용자 이름 조회
    */
   @POST("getName")
   String getName(@Query("id") Long id);
}

주의: 메서드 요청 경로의 시작에 /를 사용할 때는 주의가 필요합니다. Retrofit에서 baseUrl=http://localhost:8080/api/test/인 경우, 메서드 요청 경로가 person이면 전체 요청 경로는 http://localhost:8080/api/test/person입니다. 메서드 요청 경로가 /person이면 전체 요청 경로는 http://localhost:8080/person입니다.

주입 및 사용

인터페이스를 다른 Service에 주입하여 사용할 수 있습니다!

@Service
public class BusinessService {

    @Autowired
    private UserService userService;

    public void doBusiness() {
       // call userService
    }
}

기능 특성

관련 프로젝트 살펴보기

불러오는 중…