1

I created a sample OpenAPI spec using SwaggerHub: https://app.swaggerhub.com/apis/Leejjon/Example/1.0.0

Then I generate a server stub via Export -> Server Stub -> Spring (you can do the same via the url above to get my full code)

I am running on Windows 7 (don't laugh) and Java 11. When doing a mvn clean install I get: C:/Users/Leejjon/Downloads/spring-server-generated/src/main/java/io/swagger/api/ApiResponseMessage.java:[3,33] package javax.xml.bind.annotation does not exist

This is because Jaxb has been removed since Java 11, so I add the Jaxb API and an implementation to my pom.xml:

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.4.0-b180830.0359</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.4.0-b180830.0438</version>
    </dependency>

Now everything compiles and I can run the server using mvn spring-boot:run -Dserver.port=8080. Everything seems fine. The server seems to boot up and logging seems to indicate that it's listening for requests.

See full output here: https://pastebin.com/cDLMV8p0

When visiting http://localhost:8080/ or http://localhost:8080/examples/something I only get 404's. Anyone has a clue how to get this working?

Leejjon
  • 680
  • 2
  • 7
  • 24

1 Answers1

2

Try opening the application.properties file, look if there is a server.contextPath= variable.

Take this value and put it after your port value but before the resource value from your controller

e.g. :

http://localhost:8080/{yourContextPath}/something/?someRequestParam=someValue

Good luck