Making Eclipse Recognize Imports - java

I am trying to integrate Spring into my project in Eclipse. I am using Maven and have added the dependencies in my POM. While the maven build works, Eclipse does not recognize imports like the following.
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
How do I get Eclipse to recognize Spring imports? I am hoping there is a way to do this w/o downloading the jar files, etc.
Thanks in advance.

Eclipse doesn't support Maven projects natively. You must install a plugin (m2eclipse) to be able to use a Maven project inside Eclipse.

Another way to fix this is to open a command line, navigate to your project, and run mvn clean install and/or mvn eclipse:eclipse the first will parse the pom.xml and download all the dependencies and the second will build your eclipse meta-data files(.classpath and .project) you can even do this with the project open in eclipse and hit F5 to refresh and viola

Check your maven path in eclipse.
Window >>> Preferences >>> Maven >>> User Settings
Check for User Settings field that contains settings.xml

Related

Can not to import SpringBoot Project into Eclipse IDE

I have tried to create a new SpringBoot Project by using the Spring Initializr. I choose Java version (language as well), Spring Boot version and all required dependencies. Download the zip file (and unzip it), and after that I ask IDE (I use Eclipse IDE) to import this project, but my IDE does not find the project file. Below I will attach image, perhaps it will help you. If you ever met this problem, share your knowledge please)
Can you check if Maven is installed and configured correctly on the installation path in the Window -> Preferences -> Maven -> Installations tab.
Also please try if you can import the project either as a Maven project:
If not please try to import the project as a file system as below and see if it succeeds,

How to import a Java library in Eclipse?

I have downloaded and am trying to import this library: https://github.com/sachin-handiekar/jInstagram in one of my projects. However, whenever I point to the directory where this project is located and try to import it, Eclipse says "No projects are found to import." I even tried importing it as Android code but it didn't recognize it either. How do I import and use this library in my Android project?
Just to use this library within your project add it as a Maven dependency
<dependency>
<groupId>com.sachinhandiekar</groupId>
<artifactId>jInstagram</artifactId>
<version>1.0.9</version>
</dependency>
If you don't know how to do this check this plugin: maven-android-plugin
You can also checkout the complete source tree for the project and then go to the directory containing the pom.xml file and using Maven run mvn install to build this project and then import it to the Eclipse.
It says no projects are found to import because it is looking for the eclipse .project file which is not included in git repositories. Try the import file system option
Or better yet, try out the git plugin for eclipse
Its easy, in Activity press Ctrl + Shift + O

How to import a local GIT/Maven project/folder into eclipse?

So I did git clone to get a maven project from a remote git repository. Great! I have been working in the command line, doing git pull, commit, etc. Great! Now I want to import this project into eclipse and be able to use git inside eclipse through the installed egit. So I did a:
mvn eclipse:eclipse -Dwtpversion=2.0
And after that I am able to import the project into eclipse through the regular:
Import -> General -> Existing Projects into Workspace
But the GIT options do not appear under Team !!! :( :( :(
How do I import this project and have the git options at the same time?
First, what you want to do is import the project as a Maven project directly. Then you don't have to do all the random command line stuff, plus you have the Maven integration in Eclipse with your dependencies and pom.xml kept up to date. (You need m2e installed for this.) Go to Import and select 'Existing Maven Projects':
Then, what you should do is enable eGit on the project. Right click the root of the project and select "Share Project" under "Teams".
Select Git and it will tell you that you can use the existing repo. Voila, you're done.
Team > Share Project -> select the git project.

Errors after importing Maven project into Eclipse

I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.

How can I import jetty source code into eclipse?

I'm trying to import the jetty source code into eclipse.
I went to:
Import -> General | Existing projects into workspace
then browsed to the folder that has all the jetty related projects:
Then it doesn't seem to pick up any of the individual projects, the projects pane is empty.
What am I doing wrong here?
Jetty is a Maven project.
You'll want to do the following ...
Install the m2e plugin.
[menu] Help > Eclipse Marketplace
Search for "m2e"
Install "Maven Integration for Eclipse"
Checkout the source code for jetty somewhere onto your disk (or just unpack the source zip file)
Import the maven projects
[menu] File > Import
[tree] Maven > Existing Maven Projects
[Next button]
Browse to the top folder of the jetty source tree.
Hit Next / Finish to then import all of jetty into eclipse.
Wait for Eclipse + M2E to settle down with its compilation and project setup.

Categories