관리 메뉴

너와 나의 스토리

HATEOAS 설정하기 - swagger와 함께 사용하기 (에러 해결) 본문

개발/Spring Boot

HATEOAS 설정하기 - swagger와 함께 사용하기 (에러 해결)

노는게제일좋아! 2020. 8. 4. 13:43
반응형
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

    implementation 'junit:junit:4.12'
    implementation 'com.google.code.gson:gson:2.8.5'
    compileOnly 'org.projectlombok:lombok'
    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
    compile 'com.h2database:h2'

	implementation 'org.springframework.boot:spring-boot-starter-hateoas'
    compile("org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE")


    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }

    // spring security
    compile('org.springframework.boot:spring-boot-starter-security')
    testCompile('org.springframework.security:spring-security-test')

    // swagger
    implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
    implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
}

Error1.  "The following method did not exist: 'org.springframework.plugin.core.PluginRegistry org.springframework.plugin.core.PluginRegistry.of(java.util.List)'"

 

-> [ compile("org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE") ] 추가

-> swagger configuration에 다음의 Bean 추가

    @Bean
    public LinkDiscoverers discoverers() {
        List<LinkDiscoverer> plugins = new ArrayList<>();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
    }

 

Error2. "Parameter 0 of method linkDiscoverers in org.springframework.hateoas.config.HateoasConfiguration required a single bean, but 15 were found:" 

 

-> [ implementation 'org.springframework.data:spring-data-rest-hal-browser' ]를 지워보자.

 

 

참고 링크:

- https://stackoverflow.com/questions/58431876/spring-boot-2-2-0-spring-hateoas-startup-issue

- https://stackoverflow.com/questions/60710084/the-following-method-did-not-exist-org-springframework-plugin-core-pluginregis

- https://spring.io/guides/gs/rest-hateoas/

반응형
Comments