Not able to import Selenium jar files in Eclipse for some reason, while importing first time from quick fixes it works showing no error after saving the program it showing me that import is not working
Below is code:
Note: The issues arise only for Java projects only
A solution would be to use maven for the dependency management. Eventhough a quick demo with just a couple of dependecies should be ok in eclipse it is sometimes a pain in the a.
Try rebuilding the project. Build -> Build Project, and check the project setup. Eclipse gives also a error log when sth goes wrong. Have you taken a look at it? Problems View.
Related
I loaded a project on Spring-tool Suite but I realized that it does not correct the errors. Going to see Properties I realized that all the parameters related to the JavaBuilder that I have in the other loaded projects were missing. I think it's a Jdk problem, but I don't know how to set everything up or how to reset the project in order to have the error corrected.
thanks to anyone who can help me!
I think you need to delete the .metadata folder in your workspace.
The problem was Spring-Tool itself which had a bug where it didn't show any kind of error. There are two ways to get around the problem: delete the project from Spring-boot, delete the Workspace and reload everything. In case it is also recommended to download Spring-boot tool Suite again. In the second case it could be an error importing the project, try to import it to Intellij or another IDEE and see if you have the same problems. If you have the same problems it is a problem of loading the java libraries. To solve it you should open another project where you have no problems and once opened, go to FILE-> NEW-> IMPORT PROJECT and import your project.
When updating an external jar file which contains breaking changes, so the code at certain points will have errors (which happens and is fine), I am unable to build my project via gradle, thus EVERY import from the jar shows up in my IDE as an error (Intellij).
This makes it super hard to actually see where the errors are, since ALL imports from the jar, even though all those classes are in there show up as "errors", since build failure means gradle simply wont import the jar at all...
The end result is that my IDE shows things like this (removed package name for security reasons):
All of those model.entity classes ARE in the jar, but gradle wont import them because the build process stops at the first syntax error in the code...
Is there any way around this? How to refactor large code bases without relying on the error messages inside the gradle console (which there might be a LOT of).
I'd like to import the jar first THEN fix the syntax errors? Maybe a different gradle command? I'm simply using "clean build"
There are 2 aspects here.
grade
IDE (appears to be Intellij) - imports the gradle to create project. unless on auto refresh, requires manual reimport (refresh button) when there are changes in gradle files
in your scenario, initial state is gradle build works, Intellij works fine
you replace the dependency with 'breaking' change.
gradle build - will fail at compile stages as code is yet to the fixed
IntelliJ - still is not seeing new dependency. click the re-import
The import will always succeed unless there are errors in .gradle files
After import IDE will now reflect new dependency
In my rest API projects, IntelliJ suddenly stopped recognizing imports from the packages org.springframework.http and org.springframework.web. For example, it gives me the red squiggleys when I try to create an instance of ResponseEntity or use the #RestController annotation. I also get the red squiggleys under the corresponding import statements with the message “Cannot resolve symbol” when I hover my cursor over them.
I click the light bulb and select “add Maven dependency”, but IntelliJ cannot find any to add. Even if it could, the proper Maven dependencies are already present in the pom.xml, but they are grayed-out as if they aren’t referenced anywhere. Manually specifying different versions of the dependencies does nothing. Reimporting the project does nothing. Cloning the repo again and starting a new project didn’t help. Neither did invalidating the caches, deleting the entire .m2 directory, updating IntelliJ, restarting my machine, or fiddling with the interpreter.
The code builds and runs as expected without any problems both in terminal and in the IDE. I have no idea why the IntelliJ seems so confused. This is only happening on my machine, and I can’t think of anything I could have done to cause it. Nobody else on the team has seen this issue. It’s not isolated to any particular repo. It happens any time I try to import from these specific packages. It’s been bugging me all week, and my teammates are just as bewildered as I am. Any suggestions?
Additional Info:
Java 11.0.6
Latest versions of Maven and IntelliJ
macOS Mojave
Update
I decided to once again delete my entire .m2 directory and the .idea directory for my project. I have done this multiple times over the past week with no results. This time, when I reimported the project I found the aforementioned org.springframework.web and org.springframework.http imports are now being recognized correctly. However, IntelliJ is now failing to recognize some of the other imports, such as lombok.
I actually had this particular version of the problem last week for several hours. I then took a short break and opened my laptop to find that everything was magically back to normal. A few days later, I started having the error that I described above. These unrecognized imports seem to appear and disappear at random, regardless of the project I am working in or any changes to the code.
Let me reiterate that there is nothing wrong with the code. IntelliJ builds and runs it flawlessly, even with all the red squiggleys. There is something wonky going on with the editor. I have included a screenshot below of the current state.
Solved
I decided to uninstall and reinstall IntelliJ. which resolved the issue.
This can happen for lots of reasons:
Try the following:
(Mac users) Right click on the project -> Maven -> reimport
If that doesn't work:
Delete `.idea` folder and re import the project.
Its located in the root of the project. like this one
za$ ls .idea/
.name compiler.xml encodings.xml httpRequests/ misc.xml vcs.xml workspace.xml
If that doesn't work, make sure the jar is loaded and you can see it listed as a dependency, or import it manually. see this questions:
https://stackoverflow.com/questions/1051640/correct-way-to-add-external-jars-lib-jar-to-an-intellij-idea-project
If that doesn't work:
Delete all versions of the jar(that having the issue) from ./m2
folder. Or make sure to specify a specific version in pom.xml
Refer to the image link here Exclude from import and Completion
In Intellij settings File-> Settings, go to Editor -> General -> Auto Import -> Java section -> Exclude from import and completion. Remove those classes you have accidentally put there. It might have ever happened coz you have ever pressed the wrong button when there is an auto-suggest from Intellij.
Actually, I have the same problem a few days ago. And that is how I resolved it.
Got a new pc, and trying to import an existing maven project into IDEA (version 2018.3), with following steps:
import -> import project from external model -> maven
But, after importing, there is no src dir, I have tried many times, each time delete .idea/ before re-import.
I remember it did work before, but not this time.
And, I can compile the project successfully with mvn compile, also Eclipse could import it correctly.
Any idea what's wrong, and how to fix it?
First check if your intelliJ is collecting POM dependencies, on large projects it can go for hours. During collecting dependencies you will see no folders, but only root files.
If the above is not the case, right click on white project area/Maven/Reimport.
If you don't see it or that doesn't fix the problem, go to File->Project Structure... then choose Modules and check if you have duplicated modules and remove them.
I've addressed this problem by myself.
I've set up my IDEA using my previous setting backup, which therefore lead to the result that there are some legacy settings regarding maven and were imported by IDE.
A reasonable inference is that this is a built-in bug.
Restore the IDEA to default settings help address this problem.
Happy coding 🤣
Newbie question here...I've wrote an application in eclipse and I've added to a private github repo. I went to import the application to a new workspace so I can work out of my github location and not have to constantly copy/paste. When I import the working application as an existing project into Eclipse, everything I've imported gets hit with a "cannot be resolved" error.
I was wondering if their is something I could do to resolve this?
This happens sometimes with Eclipse. Try to clean your project(Project -> Clean). If that doesnt work restart Eclipse.
Another reason could be that you don't have the necessary jar files for your imports. If this is the case then import the jars(Right Click Project -> Properties -> Java Build Path -> Add External Jars).
If you use gradle as the build tool, just run gradle eclipse
When this happens for a single class I used to Ctrl+click on the class (Open Declaration).
Cut the contents. Save it.
Paste the contents back. Save it again.