I got a project from GitHub which is a Java spring boot application running with Maven dependencies.
I am so confused why I can't run the application successfully on STS.
There's no longer a problem on my old laptop. Because I just changed my laptop, this problem only occurred on this laptop.
The details / symptoms of the issue are:
When I typed "SpringToolSuite" on my start panel, no applications were being recognized. So I have to open STS manually from Downloads (ie. its original file location). But anyways, it is just a minor issue.
In STS, annotations such as the lombok log and most of the getter/setter methods were unrecognized.
Failed to perform "Run as Spring Boot App" from STS, but it is successful when I tried to perform "mvn clean install" to create a Maven build from command prompt.
Error message: "log cannot be resolved"
I tried finding results from other posts here but to no avail.
The steps that I import the project is:
Create another folder as the workspace.
Open STS by selecting the created folder as the workspace.
Click File > Import and import as existing Maven project (as it is a Maven-built application).
I also tried to create a Maven build from command prompt, which is successful eventually.
As the situation was so strange here, please advise further what I can do. Thanks.
Lombok has a plugin for Eclipse (and therefore STS as well) that enhances the IDE with direct support for Lombok: https://projectlombok.org/setup/eclipse
Without that extension the IDE is not really able to recognize and support Lombok.
Thanks so much for your suggestions.
First of all, I've made sure my STS the latest version. I installed it from the official site https://spring.io/tools.
I downloaded the Windows one. See image.
I executed the spring-tool-suite-4-4.16.1.RELEASE-e4.25.0-win32.win32.x86_64.self-extracting.jar file afterwards. A folder with STS application inside has been generated.
Referring to your second question, I am sure I have the lombok dependency.
This is part of my pom.xml. See image.
I also performed again the "mvn clean install". It is success and error-free.
Fyi, I also make sure every setup is right, such as:
It is pointing to the same java version as what Maven points to.
In STS, the Java compliance level is the same as the java version I defined in PATH environment variable.
Also in STS, the Installed JRE is pointing to the right folder.
But as the STS is still not recognizing Spring Boot annotations. That's why it seems weird here. For example, logs are underlined red with an error message on the IDE. Getters and Setters of #Data fields are not implicitly referenced with that spring boot annotation since they're also underlined with error.
I am new to Java from c++ and I have been trying to familiarise myself with the language.
I am trying to use the lombok plugin from IntelliJ IDEA but it does not seem to work for me at all:
This is a screenshot of my IDEA failing to recognise the "#value" annotation
The lombok is already installed on my IDEA and I have tried restore the default settings of my ide a bunch of times but I still get the same error:
This is a screenshot of the lombok plugin install on my ide
I am using the IntelliJ IDEA 2021.2.2 (Ultimate Edition).
Does anyone know what's the problem?
I have never used the Lombok plugin through the IDE. The way I do know how to use it is as follows:
Make sure that when you create a new project through your IDE that you're selecting either a maven project or a gradle project, these are project types that help you manage your dependencies in an intuitive way(I'll use maven for this example).
Go to either https://projectlombok.org/setup/maven or https://projectlombok.org/setup/gradle depending on the project type you've chosen you'll have to copy and paste the text block from these respective url's into either your pom.xml file(for maven) or your build.gradle file(for gradle)
For Maven:
For Gradle:
Paste the text block into your pom.xml or build.gradle like so(don't forget to click the M that shows up that's hovered over by the cursor, this updates your project with the new dependency so you can use actually use lombok):
Now you should be able to use Lombok and make use of all it's boilerplate goodness :)
I've been run into this issue, it was caused by Lombok version conflict, using the latest version works for me, you can use maven helper idea plugin to see if it's the same case for you.
I came across the same issue and found an intellij IDEA plugin called Delombok. It seems this plugin is part of the projectlombok. Anyone facing the same issue can try it out! By the way I am using IntelliJ IDEA 2022.1.4 (Ultimate Edition).
THE PROBLEM
I've been developing in Java for years, but a recent install of my tools on a new computer (Windows 10) has resulted in the strangest problem. When I create a new project, almost everything is underlined in red. The error reads Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor:
WHAT I TRIED:
A quick search online reveals that I should JRE System Library is most likely unbound, so I change it: Properties >> Java Build Path >> JRE System Library >> Edit:
All of the red lines go away, but I can't run my program. An Error reads:
An internal error occurred during: "Launching Main".
Model not available for helloWorld
On closer inspection, Eclipse shows an error in the src/test folder, but there are no files there.
When I restart Eclipse, all of the red lines reappear and I have to do everything all over again. It also cannot find the JUnit dependencies either, and I have to manually add JUnit 4 library to the build path.
DEETS YO:
OS Details:
Windows 10
Eclipse Details:
Version: 2019-09 R (4.13.0)
Java Details:
Java 13.0.1
Alright, so none of the posted suggestions worked but I independently found out what was wrong. In general, I've found that this solves a lot of weird Gradle activity, including the ominous "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.6-all.zip'" that a lot of people have problems with once they try to use Gradle with new versions of Eclipse.
Solution
When you install Eclipse, there's a Buildship Gradle Integration plug-in that is visible in the Eclipse Marketplace (it has a little graphic of an elephant next to it). When you get modern versions of JavaEE Eclipse, it comes with that installed.
The problem is that this isn't the most updated version of it.
So you have to click the button that reads "installed" and it'll update it. After you update it and restart Eclipse, your most recent version of Gradle will work.
When using gradle run this:
gradlew cleanEclipse eclipse
this will re-generate the eclipse project and this helped me
Under a fresh Eclipse, we encountered this "Model not available problem" on projects that do not use Gradle, but maven.
To update gradle did not change anything. We assume that there is a conflict between m2e and this plugin. We found 2 solutions :
A) Add gradle nature (even if unused)
Right-click on the project
Configure
Add Nature (elephant logo)
Run your app, enjoy
B) Uninstall gradle. (if not used and not mandatory for your eclipse version)
Help/Eclipse MarketPlace
Search "Gradle"
Go to "BuildShop Gradle Integration 3.0" (the elephant) which is indicated as installed and clic on the grayed installed button.
Uninstall it. It will restart eclipse.
Run your app, enjoy :)
In my case it is resolved by updating Buildship Gradle Integration 3.0 from Eclipse market place
I came across a Maven project which has Groovy files in it. Those Groovy files were not getting recognized during initial compilation. So, I added groovy libraries in build path.
Due to that, when autobuild is triggered it shows the following error window:
Also, I am not able to decompile the dependent jars and all the projects went into error state.
I tried restarting my eclipse and it asked me to install the following plugins:
When I click on install, it prompts me the following error window:
I am not sure if reverting back all my changes of adding Groovy libraries is a good idea! Any leads on handling this situation will be appreciated.
It sounds like you added the Groovy Development Tools to eclipse. GDT patches the Java Development Tools (and provides LanguageSupportFactory class mentioned above). If you use the incorrect version of GDT to patch JDT, eclipse can end up in a very bad state.
I recommend looking at Help > About Eclipse Platform > Installation Details > Installation History. You can revert to a previous state where GDT was not installed. If you want to add back GDT, be sure you use the update site that matches the version of eclipse you are using.
So I have a maven module (module-A) in IntelliJ. I recently moved some classes from it into another new maven module (module-B) and added a dependency to it. Once I had done this I also modified the signature of a method of one of the moved classes (now in module-B).
I re-imported the poms so that IntelliJ would pick up the dependency changes and ensured all Java imports for the affected files were correct again. Now when I attempt to run my webapp (which depends on the two modules) I get a compile error in a class in module-A calling the modified method of the class in module-B.
The error message is basically saying that that method doesn't exist but believes the old method still exists! I click on the 'make' error and it takes me to the line in a class in module-A calling the modified method...the weird thing is, IntelliJ knows it is fine in the file. i.e. The method is not underlined in red like a compile error would normally be, but the class file name is :(
I compiled it from the command line using 'mvn install' (having also installed module-B) and it is all successful. I have deleted the classes directory in the target of both module-A and module-B and also invalidated IntelliJ's caches and restarted...still happening...any ideas?
I found out that this might help:
File -> Invalidate Caches
Maven Projects -> Reimport should help.
I spent a few hours on this same issue. All of the cleans in the world didn't help.
I deleted my out and target directory in my project and recompiled - that cleared it.
Edit: There is also a magic feature under the file menu: "Invalidate Caches / Restart" This fixes a bunch of "intellij is confused" problems.
Change "Java Compiler" setting in IDEA (User compiler javac in-process) to fix the problem.
Try to mvn clean your projects and mvn install your project B.
The maven integration with intelliJ is kind of buggy when you use the make command directly provided by Intellij. You should directly use the mvn commands, or start them from the maven panel.
I ran across a very similar problem that was driving me insane.
My code would compile fine with the ant task I normally run, but it would not build in IntelliJ, complaining about "Cannot Find Symbol blah blah"
Turns out, you can add "Excluded" files for the compiler. My file somehow got added to that list.
This list is located in File > Settings > Compiler > Excludes (IntelliJ 13)
Following steps should fix this problem :
delete .IntelliJIdea12 / .IdeaIC12 older under c:/user/.../
Invalidate Intelli's cache: File > Invalidate Caches.
This re-indexes your workspace on start-up and also clears your local history. Before you do this, commit or back up all your uncommitted changes.
Once your workspace is back after indexing, do a maven clean install.
when the build is successful, click on Maven Re-imports
This worked for me, I think it should work for others too with a similar problem.
So just stated it up this morning and it's all working!
Last night what I did do was open a new project (intelliJ project) from module-A's and module-B's parent pom and successfully got it to build, possibly doing that and then opening my original project again fixed it somehow...very annoying though
The behavior I see is similar to the one described by the original author.
Error markers show up on the right side of the editor in Intellij 14 and less so in 13.
This happens also if using Scala instead of Java and using SBT instead of Maven.
Also noticed this occurs after the second project is loaded. The first is always fine.
(After much trial and error) Figured it might be caused by Intellij's internal caches becoming somehow corrupt. "Invalidate caches" worked sometime and sometimes did not.
I work with a number of projects using Play! Framework and they use different versions of Scala and lots of dependencies.
I hypothesized the caches become corrupt because the internal key Intellij uses is not good enough to handle situations when the same class, loaded multiple times in different jars, has different signatures, and this results in the editor errors while external builds work fine.
Then the "Changing Ivy Cache Location for sbt projects in IntelliJ IDEA?" post gave the idea to segregate the ivy cache SBT and Intellij use in the hope that the ivy path is part of the internal cache key.
Paul Phillips of TypeSafe provide the "SBT extras" tooling and here I found a way to instruct SBT to use a project based ivy home, cache and SBT boot:
https: //raw.githubusercontent.com/paulp/sbt-extras/master/sbt
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
How to configure Intellij
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/ec8ec491-6d0c-4691-9598-916a63ba65ef/12.02.2014-08.59.png
Then did the same for the external SBT build to work in sync
: see http://content.screencast.com/users/SemanticBeeng/folders/Snagit/media/dcb287c4-200f-47f3-a937-42865675a22b/12.02.2014-09.01.png
Finally got rid of the user home based .ivy2 and all the contents.
To be sure Intellij does not use this folder I made it readonly.
This was a mistake. Intellij seems to silently fail resolve dependencies if you do this.
This solved the errors and believe they will not come back. :-)
If Intellij guys hear this: please test your releases (Scala, SBT, editor) with all the Play Framework templates from TypeSafe. The problem becomes apparent quickly this way.
I just had a similar issue that was driving me insane. I had done all the other things mentioned in the answers above because I have used Intellij forever, but none worked. In the end I found out that in the maven projects portion of Intellij, one of my modules had been marked "ignore" a simple unignore command from the context menu did the trick.
In my case, I had manually marked a directory as "Test Sources Root" but IDEA marked it on a parent Maven project. Unmarking it in File->Project structure...->Modules fixed the problem.
This could happen if you are using different version of java while building outside IntelljJ. My IntelliJ had java10 and I was using java8 while building at terminal. Changing java version to IntelliJ fixed this issue for me.
I had a very similar behavior. Running (Scala-)tests would always fail due to errors in unrelated java classes during the 'make' step.
It turned out, I had included a 'global' SDK library that collided with one of the dependencies from the project. A proper helpful error message only showed up after I deleted the 'make' step from the test.
I then deleted the duplicate library, re-added the make step to the test and everything is now working fine.
I ran into this problem today after upgrading from 12 to 13.
Later I fixed issue as I used the same name for Project and Module and looks Intellij allows this but cannot handle it correctly.
No idea why setting will impact the compilation, although there is no error in java editor. Should be a bug in version 13.
I was facing a similar issue after upgrading from IntelliJ 12 to 13. After multiple uninstalls and re-installs (of multiple intelliJ versions), numerous cleans and .m2 repository clearing, I finally figured out what my issue was.
In my intelliJ settings, the repositories mentioned in my main POM file could not be connected to. this was in turn due and alternate repository that was mentioned as a part of my pom file.
Once the POM was made to point to the correct repository, all my classes had their compilation issues resolved.
To check if your repositories are being connected to, go to File -> Settings -> Maven -> Repositories
Here, your indexed maven repositories should be connected to successfully. If they are not, then intelliJ will not be able to resolve most 3rd party and module dependencies.
I'm embarrassed to say, but we also had this problem, but it was due to a mistake in our package name.
When creating the packages for a new project I accidentally created a package called "org.package".
My project then had a directory structure like:
/src/main/java/org.package/
Which caused all sorts of havoc with IntilliJ.
Once the correct folder structure was created on the file system, IntelliJ worked great.
/src/main/java/org/package/
Note the difference in /org.package/ vs /org/package/
The fix was i made it javac instead of Ajc and i put 1.8 of course according to your jdk version.
for some reason when i invalidate and restart intellij it was set to be the default !
my version is
This happened to me...what fixed it was realising there was an extra main.iml file in the source directory. Deleting that instantly made the compile errors go away.
None of the above answers worked for me.
In my case, I had to finally create an explicit Maven Run Configuration for the module (with Command Line as "clean install") and then run it.
It is in Run > Edit Configurations
close the project
go-to the project folder and delete idea project file and .iws file
run mvn idea:idea
restart the project.
seems idea keeping the old project dependencies without cleaning even though we run file -> invalidate caches
Setting the proper Java SDK solves the issue
Right click on the project and select "Open Module Settings"
Check if you have the right Java SDK under platform settings
Check the SDK under Modules
Rebuild the project from "Build" menu
Delete the installation directory.
Remove the following directories:
~/.config/JetBrains/
~/.cache/JetBrains/
~/.local/share/JetBrains/
This will remove each and every configuration plus installation of jetbrains tools, be it IDEA, goland,etc.
Now install everything from scratch.
That's the only way it worked for me