Swagger with Spring Boot and AWS Lambda - spring-boot

I am trying to deploy a spring boot , Java, Swagger application, everything is working fine except the swagger UI.
I am getting this below error.
File path not allowed: /swagger-ui.html
at com.amazonaws.serverless.proxy.internal.SecurityUtils.getValidFilePath
(SecurityUtils.java:192) ~[task/:na]

This is an old bug in Amazon's library.
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-spring</artifactId>
</dependency>
Use the latest (or higher than 1.2).
https://github.com/awslabs/aws-serverless-java-container/pull/205

Its a configuration issue. You need to check the configuration part. I have mentioned few tutorials,have a look int it.
Configure Swagger With Jersey and Spring Boot
Spring Boot + Swagger2
How to add Swagger to Spring Boot -Video tutorial
How to configure Swagger in Spring Boot -Video tutorial

Related

why Swagger UI is not working in Spring Boot 3.0 version?

I'm trying to run my Spring boot application which is based on version 3.0 with swagger UI and I'm getting a lot of exceptions I have explored many sources like youtube and documentation but I'm unable to find the solution.
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
if any one can share the solution it will be very nice.
SpringFox is for all intents and purposes dead / abandoned project. It hasn't has a release since July 2020, note the 3.0.0 is their support for Spring Boot 2.0.0. The breaking API changes, if you haven't already been affected by them in prior releases, have finally broken it for you with the latest Spring Boot 3.0.0 which introduces significant breaking changes in Spring Framework and Spring Boot.
One of which is a change to how Autoconfiguration's must be registered in Spring Boot. The old method was deprecated in 2.7.0 and removed in 3.0.0. Springfox will not work without manually creating the beans required, and this is assuming that there is not more breaking changes in the other Spring components it uses.
There is an alternative in the form of SpringDoc which gives you the same functionality of Springfox's implementation of the OpenAPI / Swagger spec and more.
There is a simple migration guide to move from Springfox to SpringDoc.
I had problem to configure swagger with spring 3.0.2 version. I've tried several solutions and always get the "Whitelabel Error Page" error. So I decided to change the spring version to 2.7.8 and it worked. I would also like to know why it didn't work with version 3.02

Spring Boot [2.6.6] is not compatible with this Spring Cloud release train

We're trying to upgrade spring boot version to 2.6.6 and faced up with "Spring Boot [2.6.6] is not compatible with this Spring Cloud release train" (when running integration tests).
In additional
spring-cloud.version = 2021
We're using org.springframework.cloud (spring-cloud-starter-openfeign & spring-cloud-openfeign-cores) 3.1.1
according to the documentation , spring boot support 2.6.6 should be compatible.
You could try and set your spring cloud version to
spring-cloud.version = 2021.0.1
If it is not that simple mistake I am sorry. The documentation that you linked to is correct. Spring Boot [2.6.6] is compatible with spring-cloud.version 2021.x.x. openfeign 3.1.1 is also part of springCloud 2021.x.x. I have multiple project with this configuration running. In all of them the runtime as well as the integration test are working properly. Otherwise a stacktrace would be nice to gain further information :)
I have multimodule project using maven.
After migrating for Spring-Boot version 2.4.2 to 2.6.6, I face multiple issues.
First one is the application won't be able to find the Bootstrap class. The error is:
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.Bootstrapper
To fix the issue I need to add the dependency in the pom.xml of the module:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
Second problem I face is to this "Spring Cloud release train"
In this case I need to upgrade the Spring-Cloud version to "2021.0.1" which is compatible with Spring-Boot 2.6.6
Third problem I face is this error while starting the application:
"No spring.config.import property has been defined"
The reason for this error is that some of the "bootstrap.properties" files are deprecated in the new version so application won't starts. To fix this, we need to add below property in application.properties or application.yml file.
spring.config.import=optional:configserver:

What is the web dependency in the Kotlin Spring Boot tutorial?

In the Kotlin Spring Boot tutorial it asks you to include the web dependency, like this:
but in the actual Spring Boot initializr, I don't see that:
What's the web dependency that's required? Is it Spring Web Starter? Is this tutorial out of date and/or obsolete?
spring web starter is the one you need to select it's what they refer to in the tutorial.
its the full name for it.
if you look in the tutorial they later show the pom.xml There you can see that they have declared the:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
and the tuturial still seems okey so go for it.

Do we really need to add spring boot starter web for spring boot admin clients?

Version 1.5.4 was working fine without extra declaration of starter web in POM of Spring Boot Admin Clients. When I upgraded to 2.0.1, I had to add starter web to POM to make it work. Without starter web in client apps, there is no error or no log related to registering the application.
It's not documented anywhere as far as I know. Can anyone please confirm?
Spring Boot Admin 2.x can run on netty and on tomcat. So if you want to run on tomcat you have to explicitly import the spring-boot-starter-web.
The getting started guide contains this dependency http://codecentric.github.io/spring-boot-admin/current/#set-up-admin-server

spring actuator for standalone spring boot application

we have standalone spring boot application which triggers some quartz jobs based on triggers. it is standalone jar file , no application server involved.
i am planning to add Spring actuator to it. is it possible to add actuator to spring boot application which is not running on any application server.
i did search in google and spring.io website but haven't found any relevant info. if i can add can someone help me how to do it or any link for documentation.
Thanks
Try adding the spring-boot-starter-web dependency to your pom.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I had the same issue and this resolved it for me.

Resources