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

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")

Related

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?

Gradle sub projects won't compile with dependencies on sub-projects

I have following project structure with gradle 6.8.3 version and spring-boot 2.4.3
Project-A
|
|___ Project B
|
|___ Project C
Project A being root project and project B is being dependent on project C.
Project C build.gradle
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'maven'
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-logging'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
Project B build.gradle file
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'maven'
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation project(':PROJECT-C')
implementation 'org.springframework.boot:spring-boot-starter'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-logging'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'project-c:0.0.0-SNAPSHOT'
}
test {
useJUnitPlatform()
}
When trying to build project-c it throws
Following are the details for more information.
JDK11
IntelliJ Idea
Error thrown
What went wrong:
A problem occurred evaluating root project 'project-c'.
Project with path ':project-b' could not be found in root project 'project-c'.
Any help is highly appreciated.
settings.gradle file at root level
rootProject.name = 'Project-A'
include 'Project-B', 'Project-C'
Also I have a settings.gradle file in all sub modules also. Content of settings.gradle in sub modules contains only name of the project
Assuming that your setup in the settings.gradle file is correct:
In your dependencies block in project B build.gradle file, instead of
implementation project(':PROJECT-C')
try
implementation project(':Project-A:Project-C')
as project a is the root project.
In my case I had a rouge settings.gradle inside one of the child project dir 🤦‍♂️ and it managed to waste couple of my hours. 😔

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()
}

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.

AnnotationProcessor and dependencies

I'm using gradle / querydsl and JPA 2.1.
I would like to generate the querydsl metadata using APT (QEntities).
To do that I'm using the gradle-apt-plugin and gradle 4.7
In my project I configured the compileJava option using :
compileJava {
options.annotationProcessorGeneratedSourcesDirectory = file("$projectDir/src/generated2/java")
}
In my dependencies I added
compile 'org.springframework.boot:spring-boot-starter-data-jpa'"
annotationProcessor "com.querydsl:querydsl-apt:$querydslVersion:jpa"
The spring starter adds the org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final jar that contains javax.persistence.Entity class to the compileClasspath.
When launching the compileJava task I got the error :
caused by: java.lang.NoClassDefFoundError: javax/persistence/Entity at com.querydsl.apt.jpa.JPAAnnotationProcessor.createConfiguration(JPAAnnotationProcessor.java:37)
Don't understand why the annotation processor cannot load this class.
In case somebody else is searching. This is my full solution (based on your response). The important parts are the net.ltgt.apt* plugins to activate the code generation also in eclipse, and the last three querydsl dependencies.
buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins { // activates the automatic code generation
id 'net.ltgt.apt' version '0.18'
id 'net.ltgt.apt-eclipse' version '0.18'
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webflux'
// querydsl
annotationProcessor 'com.querydsl:querydsl-apt:4.1.3:jpa'
annotationProcessor 'org.springframework.boot:spring-boot-starter-data-jpa' // needed because the query dsl annotation processor doesn't recognize javax.persistence.Entity
compile 'com.querydsl:querydsl-jpa:4.1.3'
}

Resources