Gradle in Spring Boot project not recognizing Java jdk in Path - spring

I have a spring boot application where the gradle version is 7.0.
I had to change my openjdk 16 to openjdk 11 because I want to use keycloak with the project.
After I updated the Path, my java 11 gets recognized:
But my gradle is still stuck on the other version:
Edit: I have noticed that the error is in my build.gradle file:
Things I have tried:
restarting my pc
deleting cache folders for vscode
putting a JAVA_HOME into my path and link it and reverted it(I checked everytime with a new powershell window to make sure that it has updated and it always worked)
test another spring project (The other spring boot app does not have this gradle issue)
Anything else I can try?

I would look closely at the other spring boot app that does not have this gradle issue. VSCode has a habit of keeping cached versions of files around, but really you want the gradle files to be interrupted so it downloads new dependencies. I would look into that next, if you can't figure out what makes your other project work and this one not.

Related

Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Setup:
Intellij IDEA community edition 2020.2
Spring Bott starter parent: 2.3.5
Java 11
WRAPPER_VERSION: 0.5.6
mvn 2
Hi,
I googled a lot e.g. here but I just can't fix it.
I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java.
e.g. It reports:
Cannot resolve symbol String
I tried:
invalidate caches and restart
delete .idea folder and reimport
checked sdk setup
mvn reimport
mvn clean and then rebuild (while the build is always successful)
I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.
UPDATE:
I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed
When I execute Analyze->inspect code I get the following:
I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.
IntelliJ Ultimate 2020.3
Spring Boot Starter Parent 2.4.2
Java 15
Maven 4.0.0
Maven Wrapper 0.5.6
The easiest solution is to generate your project again with Spring Starter.
After you set up everything you need at pom file -> Generate -> Download it.
Open with your IDE and copy-paste all code sources which you have already written.

Grails - IntelliJ can't resolve symbols and objects

ItelliJ can't resolve grails symbols. For example symbol 'group' in UrlMapping.groovy.
It's happening in every project with grails 3 or greater (in grails 2.4.4 everything works fine).
I did try to import project, open project, create new project in IntelliJ, create project in 'grails' interactive mode etc.
My suspicion is that either I'm doing something wrong with opening/creating Gradle project or maybe there is something wrong with my settings in IntelliJ.
This is example of that behaviour:
I'm using following versions:
IntelliJ IDEA:
Grails installed with sdkman - version 4.0.3
Java installed with sdkman - version 8.0.242.hs-adpt
How can I set IntelliJ to work just fine with grails?
Any help would be appreciated, thanks in advance!

MULE 3.8.1 Hibernate 4.3.11 - org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile

I am developing an application for MULE ESB CommunityEdition (3.8.1 version).
I have included (provided by MULE) SPRING 4.1.6.RELEASE in project.
For persistence layer I set up Hibernate 4.3.11.FINAL.
My code is based on this idea (https://www.ricston.com/blog/jpa-mule/).
So basically i have included in the project (besides MULE dependencies):
hibernate-entitymanager (4.3.11.Final)
hibernate-core (4.3.11.Final)
hibernate-jpa-2.1-api (1.0.0.Final)
spring-orm (4.1.6.RELEASE)
And everything was working perfectly fine until i started to use Java 8 API...
Whatever I do: any lambda, stream or anything I am still getting error:
org.hibernate.jpa.boot.archive.spi.ArchiveException: Could not build ClassFile
What I did until now:
tried to add org.javassist dependency (in version from 3.18.0-GA to 3-22.0-GA) - nothing happened,
tried to exclude org.reflections.0.9.9 dependency (mule is including that in some its core dependencies): also nothing happened
I spent on this about 5 hours I am really close to give it up... I really need hibernate cause this project will include many db operations
What else Can i Try to do?
Problem solved!!
I was using mvn dependency:tree to check if there are any org.javassist dependencies in project.
And there weren't...
Then I checked the folder: {mule_home}/lib/opt and there was an old version of org.javassist library!
So: I downloaded latest org.javassist jar and I put it in the {mule_home}/lib/user folder.
Now it works like a charm :)
Please check if your Anypoint Studio is pointing correct JDK.
Check below
Preference> Installed JRE >> It should have JDK 1.8 checked.

Hot swap available by maven wrapper (mvnw)?

I added spring boot dev tool dependency in current Spring boot application, but when running the application by mvnw spring-boot:run It seems not recognized the change made in Java
I do use Eclipse to make the code change and enable automatically build. and refresh my code. So i think the latest .class file should be under /target directory
So does mvnw supports hot swap at all?

How to have Buildship recognize existing projects in Eclipse Mars

I just converted my Maven project to a gradle project. It was a multi project structure:
master-project
pom.xml
---->project1
-------->pom.xml
---->project2
-------->pom.xml
---->project3
-------->pom.xml
I ran a gradle init on it and have this structure now:
master-project
build.gradle
---->project1
-------->build.gradle
---->project2
-------->build.gradle
---->project3
-------->build.gradle
Everything builds fine, and I have been able to get some things done with that I couldn't figure out how to do with Maven, so that's great. Next step was to integrate that into the IDE since the Maven Dependencies are gone since I have removed the pom.xml files.
However the project isn't recognized as a gradle project - and I am not sure how to change that?
In Eclipse Mars it's still recognized as a Maven build, not gradle....
Thanks in advance.
EDIT: I reimported the projects which enabled the plugin for Eclipse. Now I am having weird behavior.
The build works from the command line, however when attempting the same execution from within Eclipse, it fails trying to copy the file dependencies.
For example:
Couldn't copy dependency jakarta-regexp-1.4.jar
java.nio.file.NoSuchFileException: C:\Users\user.m2\repository\jakarta-regexp\jakarta-regexp\1.4\jakarta-regexp-1.4.jar -> build\jfx\app\lib\jakarta-regexp-1.4.jar
I haven't changed the repo from maven yet - just changed the build scripts. This is running from the master project. So I am confused as to why the script would work from the commandline but not from within eclipse.
EDIT 2: Turns out this behavior is also present when running from the command line when the --daemon flag is set. Is there anyway to run the tasks without the daemon in Buildship? Or perhaps a way to fix this issue when the --daemon flag is enabled?
Thanks.
The issue with the build was that there is a leak in the JDK when bundling the JRE with the native app. This only happens when running with the --daemon flag (which all IDEs user). Therefore until this is fixed you will need to run gradle --stop and then run the clean.
The plug in I am using is no longer running the native task when running with --daemon.

Resources