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).
Related
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();
After adding groovie-all:3.0.8 into my build.gradle, the downloaded jars are in different version as shown bellow. Each of this jars has its 3.0.8 version and I don't know why they aren't download instead.
Appreciate any help
Thanx
Since Groovy 2.5, groovy-all is just a pom which brings in the equivalent component jars, see the according release notes. This explains that you see no groovy-all.
Regarding the version numbers: spring-boot defines the grooy version, you can print it with:
ext {
// versions taken from Spring BOM
GROOVY_VERSION = dependencyManagement.importedProperties['groovy.version']
println GROOVY_VERSION
}
and I expect it is 2.5.13 which for example is included by Spring Boot Version 2.3.4. Unfortunately you didn't specify your used Spring version.
With Spring Boot you include Groovy normally just with
compile "org.codehaus.groovy:groovy-all"
without a version number since Spring Boot defines the version.
So the question is how to override the provided Spring version - alternatively you can increase the used Spring version to get a more recent Groovy version.
To override the Spring version just exclude Groovy, eg see this SO posts:
https://stackoverflow.com/a/50972674/3181392
https://stackoverflow.com/a/47355002/734687
E.g. use:
ext['groovy.version'] = '3.0.8'
To see which component included the wrong version you can execute the Gradle task "dependencies" (find it in IDEA under the help categegory). In this answer I assumed it was Spring (and I am sure it was).
I've been trying to create an integration test using the embeddedKafka, but I'm getting problem of missing dependency when trying to run it, this is the error:
Unable to load class org.springframework.kafka.test.EmbeddedKafkaBroker due to missing dependency org/I0Itec/zkclient/serialize/ZkSerializer
I saw some stuff saying that this is related to my dependencies, so here is my dependencies:
springBootVersion = '2.3.5.RELEASE'
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.kafka:spring-kafka:${springBootVersion}")
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}",
'org.spockframework:spock-core:1.2-groovy-2.4',
'org.spockframework:spock-spring:1.2-groovy-2.4',
'com.microsoft.azure:spring-data-cosmosdb:2.3.0',
'com.nimbusds:oauth2-oidc-sdk:5.64.4',
)
testCompile("org.springframework.kafka:spring-kafka-test:${springBootVersion}")
So, my question is, am I missing something?
EDIT
After changed the versions as indicated, I got a different error:
Error creating bean with name 'embeddedKafka': Invocation of init
method failed; nested exception is java.lang.NoClassDefFoundError:
scala/math/Ordering$$anon$7
I've added the scala dependencies, but still having the same issue:
testImplementation("org.scala-lang:scala-library:2.12.11")
testImplementation("org.scala-lang:scala-reflect:2.12.11")
You somehow have a mismatched kafka Vs. kafka-clients jars on the classpath; they all must be the same version.
You generally should not specify a version on boot's dependencies and use its dependency management instead.
You are pulling in spring-kafka 2.3.5 whereas spring-boot 2.3.5 requires spring-kafka 2.5.7.
Spring-kafka 2.5.x uses the kafka-clients 2.5.1.
See here for how to override versions of kafka jars when using a different version to the version that Boot prescribes.
the Kafka Client libraries for a time were inlining a particular version of the Scala library. This caused problems for those of us wanting to use the kafka client library with a slightly different version of Scala than that inline version.
In this cases the version of Scala they were using inline is Scala 2.12.10
They removed this dependency in later versions and this was backported as fixes (the earliest being 2.8.0) https://archive.apache.org/dist/kafka/2.8.0/RELEASE_NOTES.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.
I have the folowing Error: "java: name clash:save in JpaRepository and save in CrudRepository have the same erasure, yet neither overrides the other."
I am using Intellij IDEA with dependencies:
Hibernate 5.2.9-5.2.9
Spring Data JPA-1.3.3
Spring-4.3.8.RELEASE
I am using:
#Repository
public interface PropietarioRepository extends JpaRepository<E, K>{}
as Data Access Layer.
4.3.8-release is the latest stable version of Spring. 1.3.3 is a release from 2013, 4 years ago. Its pom indicates that it relies on spring 3.1.4.RELEASE.
Use a recent version of spring-data-jpa, that is compatible with Spring 4.3.8.
The latest stable version, compatible with spring 4.3.8, is 1.11.3: http://docs.spring.io/spring-data/jpa/docs/1.11.3.RELEASE/reference/html/#dependencies.spring-framework