org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class cannot be opened because it does not exist - spring

I have this gradle configuration with the following dependencies:
plugins {
id 'org.springframework.boot' version '2.6.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = '......'
version = '0.0.1'
sourceCompatibility = '11'
ext {
set('springCloudVersion', "2021.0.1")
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer'
implementation 'org.codehaus.jettison:jettison:1.4.1'
implementation 'com.netflix.eureka:eureka-core'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'javax.validation:validation-api'
implementation 'org.hibernate.validator:hibernate-validator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.threeten:threetenbp:1.5.1'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'joda-time:joda-time:2.10.13'
implementation 'org.springframework.security:spring-security-core'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.json:json:20211205'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.13.1'
implementation 'org.springframework.amqp:spring-amqp'
implementation 'org.springframework.amqp:spring-rabbit'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'org.parboiled:parboiled-core:1.4.0'
implementation 'commons-validator:commons-validator:1.7'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'org.springframework:spring-oxm'
implementation 'org.springframework.ws:spring-ws-core'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
runtimeOnly 'org.postgresql:postgresql'
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation 'org.liquibase:liquibase-core'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
When I start the application I get this error:
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
Do you know what dependency should be added or some dependency is missing?
P.S
The problem comes form this dependency:
implementation 'org.springframework.cloud:spring-cloud-starter-hystrix:1.4.7.RELEASE'
implementation group: 'com.netflix.hystrix', name: 'hystrix-core', version: '1.5.18'
Do you know how I can fix it?

I think you question has been already answered; please, consider review this SO question.
You need to include the following dependency:
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.2.10.RELEASE'
Because you are using Spring BOM maybe this will be enough:
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'

Related

Redis OM Spring - Gradle issue: not generating meta classes "com.redis.om.skeleton.models.Person$

I am trying to use gradle for this project https://redis.io/docs/stack/get-started/tutorials/stack-spring/. My build.gradle is this one:
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.2'
id 'io.spring.dependency-management' version '1.1.0'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation "com.redis.om:redis-om-spring:0.6.4"
implementation "io.springfox:springfox-boot-starter:3.0.0"
implementation "io.springfox:springfox-swagger-ui:3.0.0"
}
test {
useJUnitPlatform()
}
I am getting the following err while build this project:
error: cannot find symbol
import com.redis.om.skeleton.models.Person$;
It seems META model classes are not being generated by gradle. I am using Intellij Community edition with java 17.
Any help would be appreciate.
I had to add the following to my build.gradle and it solved my issue:
annotationProcessor("com.redis.om:redis-om-spring:0.6.4")

Intellij Idea Jpa Repository suggestion is not working

I created a Spring Boot project on Intellij Idea
here is my configuration
Spring Boot version: id 'org.springframework.boot' version '2.6.7'
Intellij Idea Build #IU-221.5080.210, built on April 12, 2022
here is my build.gradle file
plugins {
id 'org.springframework.boot' version '2.6.7'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'net.ltgt.apt' version '0.21'
}
group = 'io.project'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = "17"
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.8'
implementation 'org.hibernate.validator:hibernate-validator:7.0.4.Final'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
targetCompatibility = JavaVersion.VERSION_17
and here is one of my classes that extends JpaRepository
#Repository
public interface CommentRepository extends JpaRepository<CommentEntity, Long> {
List<CommentEntity> findAllByPostId(Long postId);
}
when I try to write my methods name I do not get suggestions from JpaRepository
any idea why this is happening?

Allure annotation #Step does not added into generated report

When running tests, a report is generated, but the steps are not displayed and there is no information about the execution, in the "Execution" section it is written: "No information about test execution is available."
I think I have an error in configuring Gradle. But I don't know how to fix it. I tried to add the configuration specified in the Allure documentation, but it didn't help.
build.gradle:
plugins {
id 'org.springframework.boot' version '2.2.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
sourceCompatibility = '1.8'
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-jdbc:2.2.7.RELEASE'
implementation 'com.oracle.database.jdbc:ojdbc8:12.2.0.1'
testImplementation 'io.qameta.allure:allure-junit5:2.13.3'
testImplementation 'io.qameta.allure:allure-gradle:2.8.1'
compile group: 'io.github.benas', name: 'random-beans', version: '3.9.0'
implementation 'com.github.javafaker:javafaker:1.0.2'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}

Gradle force download a different version only for a particular Transitive dependency

I am force-downloading a dependency using the below gradle-script
implementation ('org.springframework.boot:spring-boot-starter-webflux:2.2.2.RELEASE') {
force = true
}
This dependency always brings me 3.2.13.RELEASE version of io.projectreactor:reactor-core (transitive dependency)
But i want to have 3.3.0.RELEASE of io.projectreactor:reactor-core
Below is my full build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'maven-publish'
id 'jacoco'
id 'org.sonarqube' version '2.7'
}
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Greenwich.SR3'
mavenBom 'io.pivotal.spring.cloud:spring-cloud-services-dependencies:2.1.1.RELEASE'
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
//security
implementation 'org.springframework.boot:spring-boot-starter-security'
//other
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
How to force download only this particular dependency in gradle ?
Use a resolutionStrategy like:
configurations.all {
resolutionStrategy {
force 'io.projectreactor:reactor-core:3.3.0.RELEASE'
}
}

Spring Boot plugin was not found

I have an issue with gradle project
My build.gradle
buildscript {
ext {
springBootVersion = '2.1.8.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath(
"org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
}
apply plugin: 'org.springframework.boot'
group = 'com.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'mysql:mysql-connector-java'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
When I try to run build.gralde, I'm getting error
Plugin [id: 'org.springframework.boot', version: '2.1.8.RELEASE'] was not found in any of the following sources:
Gradle preferences in IDEA
I can't understand, what is the problem, I've generated project with Spring Initializer
I think, I've got the problem.
You just need to turn off "Offline Mode" and it will download it from repo
It's in the right side of the Intellij IDEA
A possible explanation is that by configuring explicitly the buildscript.repositories, you no longer have the default gradlePluginPortal().
Not all plugins are available on Maven Central for example.

Resources