1

I am using the following Maven dependencies and plugins

 <dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger2</artifactId>
  <version>2.0.3-SNAPSHOT</version>
 </dependency>

<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-spring-web</artifactId>
     <version>2.0.3-SNAPSHOT</version>
 </dependency>

  <repository>
        <id>jcenter-snapshots</id>
        <name>jcenter</name>
        <!-- <url>https://jcenter.bintray.com/</url> -->
        <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
  </repository>

in beans.xml below is the bean definition is as follows:

 <int:annotation-config/>
        <context:annotation-config/> 
        <bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"/>
<bean id="springConfig" class="com.example.SpringConfig"/>

I have referred to the following blog

I can not use the early access version mentioned in the blog as it is not available for download. I have changed the version to 2.0.3-SNAPSHOT and now I am seeing HttpMediaTypeNotAcceptableException exception. I was able to generate the WAR file and in logs I was able to see the resourcegroup that was created properly with Swagger when I tried to access it using http://localhost:8080/example/v2/api-docs the above mentioned exception was thrown.

Please help.

2
  • Have you looked at the documentation available here -> springfox.github.io/springfox/docs/snapshot also I don't think you need to have 2 annotation-configs Jun 19, 2015 at 0:16
  • yes , i have followed documentation too , bur still i m not able to resolve the exception
    – user4876003
    Jun 19, 2015 at 16:38

1 Answer 1

0

First off, it looks like the dependencies are available on Maven Central again. That's an improvement since I wrote that blog. At least 2.0.1 and 2.0.2 are available there so no need to use JCentral any more if you don't want to.

As to the HttpMediaTypeNotAcceptableException. I didn't see that during my experimentation that led to writing that blog so I can't give you a definitive anwer.

While reading your question I did notice a few related questions here on SO:

Spring MVC with Jackson 2.2: "HttpMediaTypeNotAcceptableException: Could not find acceptable representation"

Spring mvc throwing org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

Those suggest there may be some general Spring MVC configuration related to Jackson 2 that is missing or the translation of the @ResponseBody could use some tweaking for a particular method. Check those questions to see which is more applicable to your situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.