Intellij cannot resolve variables of thymeleaf templates in spring boot - spring-boot

This thread said the problem is fixed already, but it seems that I still have the problem even I have the latest version of IntelliJ Ultimate.
I have implementation "org.springframework.boot:spring-boot-starter-thymeleaf" in my gradle setting.
The application works fine, but I want to be able to use The Navigate to Declaration feature provided by IntelliJ. I already have thymeleaf-spring module in my project.

Related

Spring Batch Intellij gives error due to version. ( Just error Ultimate version )

I am trying to create a Spring Batch project. And I am creating the project.
However, after purchasing intelllij idea ultimate version, my project started giving errors. I downloaded the "community" version again and my project is working :)
So what is the problem?
If I want to run my spring batch project with intelllij idea ultimate 2022.2 version. I cannot access any spring batch objects like JobBuilderFactory, StepBuilderFactory, ItemWriter, ItemReader etc.
But if I run the same project with the free version "community" there is no error and the project works.
I can't help going crazy :)
Could not autowire. No beans of 'JobBuilderFactory' type found
I think this is because IntelliJ Idea is not able to detect that EnableBatchProcessing is importing these beans and adding them to the application context. This error is only a hint from the IDE. If you run the project with the ultimate edition, it should work as well.
There should be a difference between the community and ultimate edition WRT how to report this kind of errors, but if your app runs with the CE, it should also run with the UE.
The project that worked in the CE version did not work in the Ultimate version. However, the problem was solved as follows.
I added #EnableBatchProcessing annotation in Spring Boot Application class and I think it included it in the context.
NOTE : Usually in batch applications, #EnableBatchProcessing anotation is included in the configuration class.
When I included it directly in the main class, the problem was solved. It was a strange error.

Intellij complaining about JDK location

First Image
Second Image
As I attached 2 images, I am having trouble running my spring boot gradle project written in groovy.
As soon as I open the project, intellij tries to build the project and it fails saying Gradle Sync failed.
Since it is complaining about java home in the jdk setting, I was trying to change the path as my intellij expects. but as soon as I change it, it tells me that it cannot find android sdk location. and I have no idea why it cares about android sdk. This project is about spring batch job using gradle and groovy.
I have been searching why it happens for days now and online is talking about ardroid studio solution. and those solution do not apply to my problem.
Can someone help me with this issue please?
Thank you in advance.
It looks like you are running Android Studio instead of IntelliJ IDEA.
The former doesn't support projects other than targeted for Android, so your project will not work there.
Make sure you run IntelliJ IDEA. You can get it at https://www.jetbrains.com/idea/download/index.html.

spring initializr: Cannot import org.slf4j.LoggerFactory for Gradle projects

I'm trying to learn how to build "Spring Web" web-applications using IntelliJ IDEA, and I'm encountering a very frustrating issue when I try to create a new project using "Spring Initializr".
For some reason when I choose to create a "Gradle Project", Java or Kotlin, I'm not able to import org.slf4j.LoggerFactory
If I manually add the import statement, it doesn't resolve, and if I try to get InteliJ to automatically add the import, it instead adds the following...
import com.sun.org.slf4j.internal.LoggerFactory
This satisfies the editor, but it won't compile. It errors with...
Symbol is declared in module 'java.xml.crypto' which does not export package 'com.sun.org.slf4j.internal'
If instead I create a "Maven Project", either Kotlin or Java, then it works as expected.
I'm keeping the other settings in spring initializr set to default values, Spring Boot=2.4.2, Java=11
IntelliJ IDEA says there are no updates available.
I've made various attempts to manual add the slf4j dependencies to build.gradle (for Java) or build.gradle.kts (for Kotlin), and nothing I've done has made any difference.
I've also tried various different options for Spring Boot and Java version, and again it has made no difference.
Update...
I've confirmed that it only happens on one of my computers, my primary development desktop computer. My laptop is working fine.
I can't find anything that's different between the 2 IDEA installations.
Things I've tried so far to fix it...
Invalidate Caches / Restart
Manage IDE Settings -> Restore Default Settings
Removing and re-adding JDK's
Uninstalling and re-installing IntelliJ IDEA
I've tried everything I can think of to fix this, but the problem persists.
Basically I can't use logging in any new Gradle Spring projects. It just won't load the org.slf4j library.
Update 2...
The nature of the problem isn't exactly what I thought it was initially. It turns out the code compiles and runs just fine with the correct import, but the IDE is reporting it as unresolved.
So it seems it's just an issue with the IDE's intellisense. This seems less serious, but it's still quite inconvenient having the editor incorrectly showing errors.
After identifying that the problem was just with the IDE editor intellisense, rather than with the code dependencies or project, I was eventually able to resolve it by closing the IDE, and then deleting the system folder "C:\Users<user>\AppData\Local\JetBrains\IntelliJIdea2020.3"
After restarting IntelliJ IDEA, the folder was re-created automatically and the issue resolved itself.

Grails 3 project getting 'Cannot resolve symbol in IntelliJ IDEA' for various files

I am using Grails 3.3.8 with IntelliJ IDEA Ultimate 2018.1, but the view editor doesn't show it correctly for some reason even though I have all the configuration and dependencies. The same error/warning comes in gsp's as well. Also I am using the shiro-plugin and get the error's for its tags saying that it's not allowed.
No issue is faced while running the app but not sure why the code is not detected by IntelliJ correctly. I also tried Refresh All Gradle projects many times and even did a grails clean and build but they still show.
Note: I have the same project running on Grails 2.5.6 and it detects all fine in the same IDE version. This is when I upgraded the project to 3.3.8.

question marks in project explorer and version errors in pom.xml using Spring STS for Jhpister generated application

I have generated spring-boot and angularjs based application using jhipster and imported as existing Maven Project in Spring STS.
The application is running fine but I did not understand what are those question marks (?) in the project explorer are? and also red marks in pom.xml for versions indicate?.
But still the application is running fine. I am not sure whether these issues cause problems in future and how can I get rid of them?
The question marks are coming from the version control integration and indicate that those files are not yet committed to version control.
The squiggle lines in the pom should reveal more information if you hover over them.

Resources