OpenApi - required a bean of type 'org.springdoc.webmvc.ui.SwaggerIndexTransformer' that could not be found - spring-webflux

I'm adding Swagger to my Spring Webflux service with functional controller. First I was getting this error:
Description:
The bean 'swaggerWelcome', defined in class path resource
[org/springdoc/webflux/ui/SwaggerConfig.class], could not be
registered. A bean with that name has already been defined in class
path resource [org/springdoc/webmvc/ui/SwaggerConfig.class] and
overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true
So I added spring.main.allow-bean-definition-overriding=true to my application.properties file.
And now I'm getting this error:
Description:
Parameter 1 of method swaggerWebMvcConfigurer in
org.springdoc.webmvc.ui.SwaggerConfig required a bean of type
'org.springdoc.webmvc.ui.SwaggerIndexTransformer' that could not be
found.
Action:
Consider defining a bean of type
'org.springdoc.webmvc.ui.SwaggerIndexTransformer' in your
configuration.
Pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company/groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- For all mvc and web functions -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- Default persistence functions -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>dev.miku</groupId>
<artifactId>r2dbc-mysql</artifactId>
<version>0.8.2.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>1.5.9</version>
</dependency>
</dependencies>
</project>
The application.properties file contains:
spring.main.allow-bean-definition-overriding=true
Is there a way to avoid this configuration? What is purpose the of the SwaggerIndexTransformer? Because in the website https://springdoc.org/#getting-started they say that "No additional configuration is needed".

The error was that in the pom file the only dependency should be springdoc-openapi-webflux-ui

Related

Status HTTP 404: with a Spring Boot api web service developed with Intellij via remote Tomcat server

I created a spring boot initializer type web service under Intellij.
I can access my api in localhost via the ide server.
Example of api: http://localhost:8088/indicatorMissing/api/listCircuits
But when I create a war package that I deploy in a remote tomcat server, I have the window:
HTTP Status 404 – Not Found
Status Report Type
message /flagMissing/api/listCircuits
description The requested resource is not available.
Apache Tomcat/8.5.14 (Debian).
I tried the addresses:
:8080/missingflag/api/listCircuits
Where
:8080//MissingIndicator/api/listCircuits
Voici mon POM.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.sbvb</groupId>
<artifactId>indicateur_manquant</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>indicateur_manquant</name>
<description>indicateur_manquant</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Can anybody help me ?
Thank you

Parent Pom get version of Child Pom/dependency

I have a project like the following
mainProject - Multi Module Project structure:
pom.xml
newfolder/pom.xml
otherProject:
otherProject.pom.xml with mainProject.pom.xml as its parent pom and newFolder/pom.xml as a dependency.
see below:
mainProject pom.xml:
<groupId>test.test</groupId>
<artifactId>mainProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>newFolder</module>
</modules>
<dependency>
<groupId>test.test</groupId>
<artifactId>newFolder</artifactId>
<version>${project.version}</version>
</dependency>
newfolder/pom.xml:
<groupId>test.test</groupId>
<artifactId>newFolder</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>test.test</groupId>
<artifactId>mainProject/artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
otherProject:
<parent>
<groupId>test.test</groupId>
<artifactId>mainProject</artifactId>
<version>1.0-SNAPSHOT/version>
</parent>
<dependency>
<groupId>test.test</groupId>
<artifactId>newFolder</artifactId>
</dependency>
The problem is when I try to build otherProject it cannot find the version of newfolder because it is not pulling in the version of the project that I built it is still looking for newfolder 1.0-SNAPSHOT
Any help would be great!
I was able to get the behavior I was hoping for by adding ${project.parent.version} to the parent pom dependency. example:
<groupId>test.test</groupId>
<artifactId>mainProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>newFolder</module>
</modules>
<dependency>
<groupId>test.test</groupId>
<artifactId>newFolder</artifactId>
<version>${project.parent.version}</version>
</dependency>

RabbitConnectionFactory maven dependency

which dependencies that I need in order to use RabbitConnectionFactory? I have the below pom, but RabbitConnectionFactory cannot be resolved:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test.rabbit</groupId>
<artifactId>connector</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
</dependency>
</dependencies>
My repo is here:
https://github.com/pkid/rabbitconnectionfac
Thank you for your help in advance!
There is no such class RabbitConnectionFactory.
Where are you seeing an error?
With spring-rabbit, you would generally use its CachingConnetionFactory. It uses an underlying ConnectionFactory from the amqp-client library, which is a transitive dependency.
spring-cloud-service-connector, in RabbitConnectionFactoryCreator creates instances of these objects.

Apache Pig Java UDF - import org.apache.pig.EvalFunc; cannot be resolved

Eclipse is showing the error message import org.apache.pig.EvalFunc; cannot be resolved.How can I get rid of this error ? Below is the POM file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Pig</groupId>
<artifactId>PigUDF</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>cloudera-repo-releases</id>
<url>https://repository.cloudera.com/artifactory/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
</build>
</project>
Add pig dependency to your POM file
<dependency>
<groupId>org.apache.pig</groupId>
<artifactId>pig</artifactId>
<version>0.15.0</version><!-- or any version you want -->
</dependency>
EvalFunc class is imported from Pig Packages. So You need to add the pig dependency in pom.xml.
<!-- https://mvnrepository.com/artifact/org.apache.pig/pig -->
<dependency>
<groupId>org.apache.pig</groupId>
<artifactId>pig</artifactId>
<version>0.13.0</version>
</dependency>

Maven configuration error : repo.maven.apache.org

I am trying to create a simple java project using maven.
But I am getting one error in the problems tab with the maven configuration.
The error description is "repo.maven.apache.org"
The error type is "maven configuration" problem.
Can any one help ?
Here is my pom.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bhawani.sample.maven</groupId>
<artifactId>FirstSimpleSpringProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FirstSimpleSpringProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
</dependencies>
</project>
In case you have not already tried, try to build your project from command prompt, you will get what exactly you are missing. Additionally, need to verify if provided local repository path has been provided and if you are building it offline/behind company proxy server, add proper proxy setting as well.