My Jersey Spring Boot 1.5.2 project doesn't recognize FormDataMultiPart - spring

I tried to add FormDataMultiPart to my Jersey Spring Boot project. I am using Spring Boot 1.5.2 and the Spring Boot Jersey Starter.
I tried adding the full import org.glassfish.jersey.media.multipart.FormDataMultiPart, but it is not found.

It looks like spring-boot-starter-jersey Maven dependency does not include jersey-media-multipart. You need to add it to your pom.xml. On the other hand, Spring Boot does define a jersey.version property so you can use that to keep the versions in sync.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<!-- Multipart not included in Spring Boot. jersey.version defined by Spring Boot. -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
</dependency>
Once you add the jersey-media-multipart dependency to Maven, the FormDataMultiPart class can be found.

Related

spring boot pom ignoring updated property version

We are currently using spring boot 2.7.4 and we want to use a built in dependency of 2.7.5. I added it to the properties in the pom, but its being ignored. I have done this successfully with other dependencies.
jackson-databind 2.13.4 is a builtin dependency of spring boot 2.7.4
jackson-databind 2.13.4.2 is a dependency of spring boot 2.7.5
<jackson-databind.version>2.13.4.2</jackson-databind.version>
That does not seem to work.
Will spring just ignore an incompatible version automatically ?
Spring boot does not have jackson-databind.version variable. Full list can be seen here
But you can manually specify the required dependency version:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.2</version>
<scope>compile</scope>
</dependency>
You need to use jackson-bom.version to override via the property.
From the spring-boot-dependencies POM, which is inherited by the spring-boot-starter-parent the following is defeined in 2.7.5,
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
and and the property is set to <jackson-bom.version>2.13.4.20221013</jackson-bom.version>

java.lang.NoClassDefFoundError: Could not initialize class org.springframework.web.reactive.function.client.DefaultExchangeStrategiesBuilder

I am trying to use spring WebClient wc = WebClient.create(); in a non-Spring application, but it looks like DefaultExchangeStrategiesBuilder.DEFAULT_EXCHANGE_STRATEGIES returns null
causing error:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.web.reactive.function.client.DefaultExchangeStrategiesBuilder
at org.springframework.web.reactive.function.client.ExchangeStrategies.withDefaults(ExchangeStrategies.java:67)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.initExchangeStrategies(DefaultWebClientBuilder.java:302)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.build(DefaultWebClientBuilder.java:269)
at org.springframework.web.reactive.function.client.WebClient.create(WebClient.java:144)
I have added to my POM:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.6.5</version>
</dependency>
If your application is not a Spring Boot application and does not apply Spring Boot's dependency management, you should not use Spring Boot's starters.
Instead you should use Spring Framework's spring-webflux dependency directly, as well as a client library of your choice, like Reactor Netty, Jetty client, Apache HttpComponents...
You should also ensure that the Spring Framework BOM is applied to your project to avoid an incompatible mix of versions in your application:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>...</version>
<type>pom</type>
</dependency>

What is Spring boot 2.5 junit version?

I am using latest version of spring boot. What is spring boot 2.5.4 junit version?
spring-boot-starter-test
And for use Junit5 we should addd jupiter dependency in spring boot 2.5.4?
On the mvnrepository.com you will find it:
org.junit.jupiter ยป junit-jupiter
Version
5.7.2
There you can also click on pom.xml to show the dependency in question:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.2</version>
<scope>compile</scope>
</dependency>

Spring initializr not showing activiti dependency

I am trying to create spring-boot project for activiti but it is not showing activiti dependency.
How can I know that with which springboot version,activiti version is mapped?
Spring Initializr
If you're refererring to Activiti, this is not included in the Spring Initializr so you will need to include this manually yourself.
Go through the Spring Initializr setup
Generate and download the code to your machine
Add the Activiti dependency to your POM or Gradle file:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
</dependency>
Add the H2 dependency for database (don't use this in production):
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.183</version>
</dependency>
I haven't used Activiti before but this is based on their Spring Boot documentation.
Spring boot 2 doesn't have activiti anymore.
Manually need to add activiti dependency.
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>7.0.0.Beta1</version>
</dependency>

Spring Boot with Spring HATEOAS Maven conflicts

It seems when I add the dependency for the spring-hateoas
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.13.0.RELEASE</version>
The Class below is no longer available on the classpath
org.springframework.web.bind.annotation.RestController;
I have tried to exclude various dependencies for the spring-hateoas but the APP no longer runs.
Has anyone had any luck running spring-hateoas within spring boot.
Absolutely no problem whatsoever. The #RestController annotation is still available and you shouldn't need to do any exclusion.
In case it helps, I'm currently using version 1.0.2 of Spring Boot:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.2.RELEASE</version>
</parent>
spring-boot-starter-web provides the #RestController:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
I don't define an explicit version for spring-hateoas in my pom.xml, but my build is pulling in 0.9.0.RELEASE:
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
As a side note, I can see from the Eclipse POM editor, that Spring HATEOAS is defining dependencies on Spring 3.2.7. However the spring-boot-starter-parent project manages the versions up to 4.0.3. Can you see what version of Spring you are getting? Have you perhaps not used the spring-boot-parent as a parent project?

Resources