<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Otavio Tarelho</title>
    <description>The latest articles on DEV Community by Otavio Tarelho (@otaviotarelhodb).</description>
    <link>https://dev.to/otaviotarelhodb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F70687%2Ff7497d9b-8ed5-492e-a019-5b7409770d9f.jpeg</url>
      <title>DEV Community: Otavio Tarelho</title>
      <link>https://dev.to/otaviotarelhodb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/otaviotarelhodb"/>
    <language>en</language>
    <item>
      <title>How to use SpringFox 2.9.2 with Spring HATEOAS 2+ on a Gradle Project</title>
      <dc:creator>Otavio Tarelho</dc:creator>
      <pubDate>Mon, 30 Mar 2020 15:07:55 +0000</pubDate>
      <link>https://dev.to/otaviotarelhodb/how-to-use-springfox-2-9-2-with-spring-hateoas-2-on-gradle-project-6mn</link>
      <guid>https://dev.to/otaviotarelhodb/how-to-use-springfox-2-9-2-with-spring-hateoas-2-on-gradle-project-6mn</guid>
      <description>&lt;p&gt;A few weeks ago, I started a new project where I was challenged to use Spring HATEOAS. Well, I thought that would be really simple to implement. In fact it is, since Spring projects are well documented. What I wasn't expecting was that Spring Fox 2.9.2 and Spring HATEOAS 2+ were not compatible. This is due to the fact that Spring Fox uses the Spring Plugin Core (1.2.0.RELEASE) while Spring HATEOAS uses a newer one. &lt;/p&gt;

&lt;p&gt;Searching for a solution, I could find the following issue on Spring Fox github repository: &lt;/p&gt;
&lt;div class="ltag_github-liquid-tag"&gt;
  &lt;h1&gt;
    &lt;a href="https://github.com/springfox/springfox/issues/3052"&gt;
      &lt;img class="github-logo" alt="GitHub logo" src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg"&gt;
      &lt;span class="issue-title"&gt;
        springfox-swagger2 version 2.9.2 not compatible with springboot version 2.2.0.M4 
      &lt;/span&gt;
      &lt;span class="issue-number"&gt;#3052&lt;/span&gt;
    &lt;/a&gt;
  &lt;/h1&gt;
  &lt;div class="github-thread"&gt;
    &lt;div class="timeline-comment-header"&gt;
      &lt;a href="https://github.com/jahidakhtargit"&gt;
        &lt;img class="github-liquid-tag-img" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q9MvinP3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://avatars1.githubusercontent.com/u/39580211%3Fv%3D4" alt="jahidakhtargit avatar"&gt;
      &lt;/a&gt;
      &lt;div class="timeline-comment-header-text"&gt;
        &lt;strong&gt;
          &lt;a href="https://github.com/jahidakhtargit"&gt;jahidakhtargit&lt;/a&gt;
        &lt;/strong&gt; posted on &lt;a href="https://github.com/springfox/springfox/issues/3052"&gt;&lt;time&gt;Jul 17, 2019&lt;/time&gt;&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag-github-body"&gt;
      &lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am using swagger2 2.9.2, springboot 2.2.0.M4, Hateos 0.25.1.RELEASE. Below is the rumtime error I'm getting:&lt;/p&gt;
&lt;p&gt;An attempt was made to call a method that does not exist. The attempt was made from the following location:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;"
The following method did not exist:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jar:file:/C:/Users/EKHTJHD/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.M1/189f78af81f23eef12018a4d4cf50b8a6df8ec0d/spring-plugin-core-2.0.0.M1.jar!/org/springframework/plugin/core/PluginRegistry.class
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It was loaded from the following location:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;file:/C:/Users/EKHTJHD/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.M1/189f78af81f23eef12018a4d4cf50b8a6df8ec0d/spring-plugin-core-2.0.0.M1.jar
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry&lt;/p&gt;
&lt;p&gt;"&lt;/p&gt;
&lt;h2&gt;
&lt;span class="octicon octicon-link"&gt;&lt;/span&gt;Below is my gradle configuration:&lt;/h2&gt;
&lt;p&gt;plugins {
id 'org.springframework.boot' version '2.2.0.M4'
//id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
}&lt;/p&gt;
&lt;p&gt;apply plugin: 'io.spring.dependency-management'&lt;/p&gt;
&lt;p&gt;group = 'com.in28minutes.rest.webservices'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'&lt;/p&gt;
&lt;p&gt;configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}&lt;/p&gt;
&lt;p&gt;repositories {
mavenCentral()
maven { url '&lt;a href="https://repo.spring.io/snapshot" rel="nofollow"&gt;https://repo.spring.io/snapshot&lt;/a&gt;' }
maven { url '&lt;a href="https://repo.spring.io/milestone" rel="nofollow"&gt;https://repo.spring.io/milestone&lt;/a&gt;' }
}&lt;/p&gt;
&lt;p&gt;dependencies {
//implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compile group: 'org.springframework.hateoas', name: 'spring-hateoas', version: '0.25.1.RELEASE'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
//developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'junit', module: 'junit'
}
}&lt;/p&gt;
&lt;h2&gt;
&lt;span class="octicon octicon-link"&gt;&lt;/span&gt;test {
useJUnitPlatform()
}&lt;/h2&gt;
&lt;p&gt;If I change springboot version as below then the issue disappears.&lt;/p&gt;
&lt;p&gt;id 'org.springframework.boot' version '2.1.6.RELEASE'&lt;/p&gt;

    &lt;/div&gt;
    &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/springfox/springfox/issues/3052"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 One of the solutions from this page says that we should include Spring Plugin Core 1.2.0.RELEASE as dependency.

&lt;p&gt;However I'm using gradle which has its own dependency management rules. Due to this fact, we must force the dependency download as bellow:&lt;/p&gt;

&lt;p&gt;compile("org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE") { force = true }&lt;/p&gt;

&lt;p&gt;After adding the dependency, the project wasn't unable to run yet, not even starting. I had to do more search in order to fix that. At the end, I had to override the "discovers" bean from Spring HATEOAS with my own implementation on my project. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Only after that I could successfully use Spring Fox and Spring HATEOAS together. I created this post to simplify to other devs that are searching for a solution for the same problem. Hopefully It will be useful for someone. &lt;/p&gt;

</description>
      <category>springfox</category>
      <category>springhateoas</category>
      <category>java</category>
      <category>gradle</category>
    </item>
  </channel>
</rss>
