I just started to run spring boot application and the browser is showing this error - spring

Please explain me what is wrong here, why am I getting this type of error?
error message is : Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually:
I am new to asking questions in stack overflow , please suggest me on how to structure this question properly
[1]: https://i.stack.imgur.com/wXxnS.png

You forgot to add this annotation, please add this to main class.
#EnableSwagger2

Related

swagger-ui.html authentification

I got some java spring-boot existing project.
When I try to go to the swagger-ui.html page, I got a popin asking me my login/password.
Any idea how to disable it? What are the default value?

Open API (Swagger) non working in Spring Boot when adding context path

I have a Spring Boot application exposing REST services that are easily called on addresses like
http://localhost:8080/<controller_mapping>/<service_mapping>.
I've been asked to modify my settings in order to add a context path and have my services to respond on
http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.
Thus I edited my application.properties adding
server.servlet.context-path=/gesev-mensa
Everything works but I can't call Swagger on old address
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
I get the error Failed to load remote configuration
As suggested, I tried to add property
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
but problem persists.
I guess Swagger should be reachable at
http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
but that doesn't work.
Any hint?
Thanks for support.
Try removing
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
from your properties,
And your swagger will be available in
http://localhost:8080/gesev-mensa/swagger-ui/index.html
As per your current configuration with,
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
Swagger will be available in
http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html

Custom error page routing struts 2 + spring boot

I am trying to run a struts 2 application in spring boot provided embedded tomcat, I have managed to do so following the link https://jgalacambra.wordpress.com/2016/06/13/spring-boot-and-struts-2/. The application is working, however I am not able to get through the custom page error routing based on http error code which was configured earlier in web.xml. I have tried below solutions so far and none of them seems to work as I keep getting default tomcat error page for 404.
Things I have tried so far:
1.Disabled white label error page using.
"server.error.whitelabel.enabled=false"
2.created public/error folder in src/main/resouces and placed all html error code related html files there.
3.Also tried creating templates folder under src/main/resources and placed http error code files there.
4.I have also configured my filterregistration bean with below setting.
registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
Can someone please help what needs to be done for the error routing to work???

How to set up a swagger-ui standalone server/application?

I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.

Http 404 spring mvc [duplicate]

This question already has answers here:
Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?
(13 answers)
Closed 5 years ago.
i am not able to figure out how to solve 404 error in running an spring mvc application .
can some one please guide me how to avoid 404 error in general for spring mvc application without using annotation configuration rather xml configuaration .
Please also let me know of working war file or zip which i can import in eclipse for spring mvc directly and learn about the components .
Thanks
Prakaash
HTTP 404 mean that the requested resource (url) is not found.
In most cases either:
Your Application is not really started
Your Application is mapped to an complete different url than you expected
There is no handler for the requested url in the application
So in general: 404 is not a error by itself, in the most cases it is a bug in your application or in your understanding of how it works.
But you will not get an better answer, as long as you do not post more details about your application, as well as the URL you try to invoke.

Resources