I'm implementing a new feature in my project, in this case replacing the resttemplate with the webclient. I put this dependency in my pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>???</version>
</dependency>
I used the mvn dependecy:tree command to find out which version of spring-web was current and I verified that it was 3.2.8-RELEASE. How to find out which spring-boot-starter-webflux version I should use in my project's maven so I don't have dependency issues like this: java.lang.NoClassDefFoundError: org/springframework/http/client/reactive/ClientHttpConnector
In other words, how do I find out which version of spring-boot-starter-webflux is compatible with the version of spring-web I'm using?
if I omit the version, when building, I get the error dependencies.dependency.versin is missing.
Spring Boot includes dependency management tools to help solve this problem. If you're using any Spring Boot dependencies, the versions of all your Spring and Spring Boot dependencies should ideally be managed by Spring Boot.
A simple way to do this is to apply the Spring Boot BOM (Bill of Materials) in your Maven dependency management.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Replace the version here with the version of Spring Boot that you want to use. You can then omit the version number from any other Spring or Spring Boot dependencies.
The Spring Boot team maintains the bill of materials so that it provides compatible versioning for all the Spring and Spring Boot components as well as other libraries that the Spring framework depends on.
You can find more information in the docs here: https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.build-systems.dependency-management
If you would like to refer to Spring's version compatibility table manually, it's published in the Spring Boot docs. For example, you can find the compatible dependency versions for the current version of Spring Boot here: https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions.html
A good place to start if you're trying to identify the compatible Spring Boot version for an existing dependency is to compare their release dates. Look for a Spring Boot version that was released around the same time as your dependency. Then you can look at the compatibility table for that Spring Boot version. By using that method, I couldn't find a version of Spring Boot that's compatible with spring-web 3.2.8. That version of spring-web is over 8 years old and predates the first release of Spring Boot. You should upgrade it, if you can.
Related
I have a client application with a class that uses Specification, therefore I need a spring data jpa dependency. I know that the Boot dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
...throws an error (Failed to configure a Datasource...) at startup if you include the dependency without a Datasource configured. However, I still get the error when I use this dependency (so just Spring, no Boot) when I import my client in a Spring Boot application when the client uses this dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
Why do I still get this error? I know I can suppress the warning with a property (exclude DataSourceAutoConfiguration) or annotation, but I would prefer not to, and don't really understand why I get this error from Spring. In my understanding, Boot is opiniated throws this error to inform me of missing config, but I thought the vanilla Spring dependency would not do this. I can't find any info on expected behavior on the non-starter dependency, just on the starter dependency.
In spring boot 2.7.3 I didn't find this problem.
I'm a beginner in spring boot and I found a problem with validation It doesn't work and I tried spring validation also hibernate dependency. I have the last version of spring boot 2.7.2
I add
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>
to my pom.xml but when I add #NotNull to my bean gave me an error, and showed me there's not a #NonNull Annotation.
I faced the same issue. In my case, there was a problem with my pom. I had a dependency on the hibernate-validator. So I removed and worked for me.
my current spring boot project has spring boot starter parent dependency pom file with version as 1.5.release. Is it possible to upgrade to version 2.0. If so, how can we achieve this?
Just write <version>2.0.0</version> below the artifactId tag for the dependency.
My project is working fine with swagger2 version 2.7.0.not spring boot(spring mvc only)
I am going to upgrade it 3.0.0 but it's giving plugin errors.
java.lang.nosuchMethodError:org.springframework.plugin.core.pluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional;
My config as below:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
Update: As mentioned in https://github.com/springfox/springfox
Step 2 : Add #EnableOpenApi for open API (and #EnableSwagger2WebMvc or #EnableSwagger2WebFlux for older versions)
I added #EnableSwagger2WebMvc in class ,Then it's asking dependency of springfox-swagger2,
as this coming from :
http://springfox.github.io/springfox/javadoc/snapshot/springfox/documentation/swagger2/annotations/EnableSwagger2WebMvc.html
which is part of springfox-swagger2 dependency
Hence I am confused what to do..
can you please help cleaner approach with steps .
If I don't use #EnableSwagger2WebMvc/EnableSwagger2
Swagger is not getting loaded
Not sure if you are using Spring Boot, or regular Spring flavor, but have you followed the migration instructions posted here?
https://github.com/springfox/springfox
Remove explicit dependencies on springfox-swagger2
Remove any #EnableSwagger2... annotations
Add the springfox-boot-starter (Spring boot) or springfox-oas(Spring MVC) dependency
Check if you do not rely on removed dependecy on guava
If you are using WebMvc but you don't use the #EnableWebMvc annotation yet, add this annotation (Spring boot).
Is it somehow possible to use Maven dependency with older Spring Boot version? The project is using version 2.x and the custom dependency uses 1.5.x.
Could not found any documentation on the topic.
I'm asking because of getting a NoClassDefFoundError while introspecting class inside the custom jar file.
No. Spring Boot 2.X is a major version which is not backwards compatible with Spring Boot 1.5.X. Same goes for major Spring Framework versions, you can't mix Spring Framework 5.X and 4.X.
Maven only manages project dependencies. It has nothing to do with your problem.
Basically there can only be one version of any given combination of groupId and artifactId in any maven project. So with plain vanilla maven, the answer is 'No'. But there is the maven-shade-plugin that can be used to change the group- and artifact ids of any dependency.