I have a old project with the following Spring hateoas import dependency:
import org.springframework.hateoas.mvc.ControllerLinkBuilder;
Do you know into the latest version how I can replace this import?
There is a class WebMvcLinkBuilder.
It's used like
linkTo(OrderController.class).slash(order.getOrderId()).withSelfRel();
Related
I want to migrate old Spring project which is using this dependency:
org.springframework.boot.actuate.health.HealthAggregator
org.springframework.boot.actuate.health.OrderedHealthAggregator
..........
#Autowired
private final HealthAggregator healthAggregator = new OrderedHealthAggregator();
This Class requires import of:
'org.springframework.boot:spring-boot-actuator-autoconfigure:2.0.2.RELEASE'
I tried to use the latest version in version Spring Boot 2.6.4:
import org.springframework.boot.actuate.health.StatusAggregator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
But I can't find which class is replacing OrderedHealthAggregator
Do you know which class should be used in Spring Boot 2.6.4?
OrderedHealthAggregator was replaced by SimpleStatusAggregator.
I want to migrate old Spring project which is using this dependency:
org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint
This Class requires import of:
'org.springframework.boot:spring-boot-actuator-autoconfigure:2.0.2.RELEASE'
I tried to use the latest version:
'org.springframework.boot:spring-boot-actuator-autoconfigure:2.6.4' but ConditionalOnEnabledEndpoint is not available. Do you know which class should be used?
It doesn't exist anymore (see https://docs.spring.io/spring-boot/docs/2.6.4/api/). In version 2.2.0 it was deprecated in favour of #ConditionalOnAvailableEndpoint (see https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpoint.html).
I'm trying to use QueryDSL for Spring Data predicate resolution as well as Swagger API documentation for my Spring Boot service. However I've run into a problem. When my application starts, I get this error message:
java.lang.NoSuchMethodError: 'com.google.common.collect.FluentIterable com.google.common.collect.FluentIterable.concat(java.lang.Iterable, java.lang.Iterable)
An attempt was made to call a method that does not exist. The attempt was made from the following location:
springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels(DefaultModelDependencyProvider.java:79)
The following method did not exist:
'com.google.common.collect.FluentIterable com.google.common.collect.FluentIterable.concat(java.lang.Iterable, java.lang.Iterable)'
The method's class, com.google.common.collect.FluentIterable, is available from the following locations:
jar:file:/my_m2/com/google/guava/guava/18.0/guava-18.0.jar!/com/google/common/collect/FluentIterable.class
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.FluentIterable
I've discovered that this is happening because QueryDSL is dependent on Guava 18.0 library, but Springfox / Swagger is dependent on Guava 20.0 library, so I end up with both versions of the library on my classpath and maven seems to prioritize the 18.0 one. How can I fix this dependency mismatch? Is there any way to force QueryDSL to try to use Guava 20.0 (in the hopes that it will still function)? Or could there possibly be any other way around this?
Versions:
Spring Boot version: 2.1.9.RELEASE
This version of Spring Boot uses QueryDSL version: 4.2.1
Springfox Swagger version: 2.9.2
If using Gradle, you can force the use of a specific library version. In this case, you may use the following syntax -
configurations.all {
resolutionStrategy.force "com.google.guava:guava:$guavaVersion"
}
I'm sure there's a similar solution if you use a different build tool.
We are upgrading our existing Spring Boot (1.5) application to 2.0.0.
We connect with multiple databases and use the org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder class.
I added the dependency:
compile group: 'org.springframework.boot',
name: 'spring-boot-autoconfigure',
version: '2.0.0.RELEASE'
However, I am not able to compile the project: This class (DataSourceBuilder) does not exist in the 2.0.0 version jar.
In order to rule out gradle issues, I manually downloaded the jar and added it to the classpath. This class does not exist in the version.
Also extracted and searched the jar but this class is missing.
Can anyone help me resolve it?
The class was moved to another package. Its FQN is now org.springframework.boot.jdbc.DataSourceBuilder: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/jdbc/DataSourceBuilder.html
Old class (Spring Boot 1.x)
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
New class (Spring Boot 2.x)
import org.springframework.boot.jdbc.DataSourceBuilder;
I am working on a simple project as a point of reference for new projects or to try new technologies. The project has Hibernate & Spring capabilities.
I tried to add some anotations for validate fields. Those are the validation which I am using
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
The problem is that I need javax.validation dependecy and There are a lot of jars which includes those clases but none of Spring or Hibernate.
Which one is the standard?
Note: I check the dependency in the big project and I am using the validation-api
Try the library "Apache Geronimo JSR-303 Bean Validation Spec API", the jar is "geronimo-validation_1.0_spec-1.0-CR5.jar".
Look at this link :
http://www.findjar.com/jar/org/apache/geronimo/specs/geronimo-validation_1.0_spec/1.0-CR5/geronimo-validation_1.0_spec-1.0-CR5.jar.html
Here is maven part to add it :
http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.0-CR5
Use
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
or
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
depending on which version of the API you want to use. Note that the API is not enough, of course you also need an implementation (if you don't deploy your application in an Java EE application server). The implementation usually has a transitive dependency on the correct API jar.