I have Spring-MVC application. Files like: .project, .classpath, I dont keep in repository, I generate it by eclipse during import (eclipse import maven project).
Sometimes in Project Explorer View, project looks like:
And sometimes like below:
Can I manage this, how? I prefere second view, how convert first to second view? On screens are Eclipse Juno and Kepler, both have the same plugins installed (mostly).
In the first screenshot, the SRC/ folder is not a source folder, whereas in the second the folders SRC/main/Java, SRC/main/resources... are sources folder and not the SRC/.A right click on the SRC/ and then Build path, set a source folder should
fix that in the first image. In the second, remove from build path SRC/* and then do as above.
Related
After creating the Maven Project in Eclipse from maven-archetype-webapp archetype i have the src/main/java not seen in project explorer and advices from same topic here do not work, so it is not a duplicate, because:
in my effective POM already stays :
<sourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\main\java</sourceDirectory>
<scriptSourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\src\test\java</testSourceDirectory>
<outputDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\target\classes</outputDirectory>
<testOutputDirectory>X:\Programming\workspaceEclipse\TomkatFromArchetype\target\test-classes</testOutputDirectory>
what is actualy ok.
But after updating maven, installing, building - whatever, i can not get the damn src/main/java shown in the project explorer and can create new java classes only in src/main/ressources.
I want generally know what is the reason for that behaviour, options for folders in m2E, so i could turn it and configure in different ways manually.
Some more info:
The folder src/main/java is sort of "exist", because if i try to create the folder, it shows that there is one with this name, but is not seen.
Opening project properties (right click) -> java build path ,stays
src/main/java and src/test/java (missing), how can it be?
Solved by looking in the file explorer, is the path realy there.
If it is there,it may be added in project explorer menu. If not - you create it in file explorer and add in project explorer menu
this issue occur into eclipse many time. you need to go to Project property > project facets and click on convert to faceted from.. then apply and ok. after this you can see the src/java/main into your project resources. you can fine image below:
One solution that could work in this scenario(suddenly src main java folder vanishes) is :
delete the project from the workspace. (not from disk)
re-import the project again as Maven project.
This worked in my case.
I'm using Maven 3.3.3 together with Eclipse Mars and m2e. Yesterday, I created a new Java project and converted it into a Maven one.
Afterwards, the classpath contained only src instead of the standard src/main/java. I was surprised but I simply created the missing folders and ran m2e's "Update Project". This didn't solve the problem; m2e still insisted on using only src.
So I edited the classpath manually to end up with with the usual
src/test/java
src/test/resources
src/main/java
src/main/resources
When I try m2e's "Update Project" now, I get this error:
Cannot nest 'foo/src/test/java' inside 'foo/src'. To enable the nesting, exclude 'test/' from 'foo/src'
sigh I went to the command line next and ran mvn eclipse:eclipse to get this classpath:
src/test/java
src/test/resources
src
src/main/resources
Now, I'm completely stumped. Why is that happening?
Open your POM in the POM editor and click on the "Effective POM" tab. Search for sourceDirectory. You'll probably see something like this:
<sourceDirectory>src</sourceDirectory>
When you first converted the Java project to Maven, m2e tried to keep the classpath the same. Eclipse Java projects have a different layout by default. They use src/ instead of src/main/java/. There is no test folder since Eclipse projects usually put their tests into a different project.
To fix the issue:
Delete the sourceDirectory element from the POM (Note: It might be in a parent POM).
Go to the project
Select all the source folders
Remove them from the build path (context menu -> Build Path -> Remove From Build Path).
Update the project
The error should now be gone and the classpath should be correct.
There are two types of folders that you can create: 1) Package 2) Source Folder
1) A package looks like this
To create a package, right click on the folder you want (in my example, I right clicked on Java Resources) --> New --> Package
A pop up window that looks like this should appear
“Source folder:” That is where you choose your project. If you don’t see anything there, click on “Browse…” and find your project. If I click “Browse…” it shows this:
“Name:” is the name you will give your package.
Note: Packages should be within Source Folders. Source Folders are the parent folder.
2) Source Folders look like this:
To create a Source Folder, right click on the folder you want (in my example, I right clicked on Java Resources) --> New --> Source Folder
Under “Project name:” write your project’s name. If you need help, click “Browse…”
Under “Folder name:” write the folder name you want.
Error: If you’re trying to create a “src/main/resources” folder and you’re running into this error “Cannot nest ‘ProjectName’ inside ‘ProjectName’. To enable the nesting exclude ‘main/’ from
Solution:
I bought a new computer and installed Eclipse on it. After the ADT plugin finished downloading I tried to import my projects (composed of 4 sub-projects), but Eclipse doesn't see them!
I just click "import/general/import existing projects into workspace", select the folder containing the sub projects, hit the open button but Eclipse says "No projects found to import".
I'm using Eclipse Kepler and the projects files are directly taken from Eclipse Juno.
Eclipse need .project file to import the projects into workspace. what you can do is create a new project and copy the source and libraries into that project
Alternative method can be that create a new project and copy the .project file from that project to your project but make sure you edit the .project file and change the name of that project according to your project. read this for more information on .project file
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html
I will suggest you to use the First method .
Make sure that you've tried to:
Refresh everything
Searched for Nested Items
Go to (In the libg-gdx setup) Advanced >> Check Eclipse
And if that doesn't work, add a .project file into the folder manually
The team in which I'm working doesn't use eclipse and wants the src folder to be setup a certain way. I, on the other hand, am using eclipse. They would like the src folder to have, for example, the following structure: src/main/java/com/* However, they would like package declarations to only have com.* in them. If I go to project->properties and in the source tab remove the src folder as a source folder and then _only add the com.* folder as part of the source_ it will show com.* as a package, but I still have to add the whole path from src down in the .java files. Here's an example of what I have to do in order for eclipse to recognize the packages:
package main.java.com.parser;
And what the team wants is to have main and java just be a folder so the package declaration would just be:
package com.parser;
So although the file structure would still be src/main/java/com/parser, the package name would be as stated in the later example.
Is there a way to do this in eclipse? I've seen some people asking similar questions on here, but they seem to have no concern that the whole path must be part of the package declaration.
I would much prefer not to do this this way, but no one else is using eclipse on this project.
Thanks for any help in advance.
In the Package Explorer, right click the src folder and select Build Path > Remove from Build Path
Then find the src/main/java folder, right click java and select Build Path > Use as Source Folder
Basically this tell eclipse that java is the folder which contains the packages and source files.
P.S. This is a very normal project setup for building with Maven. If you download the m2e (Maven to Eclipse) plugins and choose to create a Maven Project (or import from the pom.xml) then Eclipse will automatically know how to correctly locate the source folder.
I have imported my maven project in eclipse using Import Maven project. It got import in eclipse project explorer, but all the source folder are opening as files and folders, its not opening as java source folder. Since its opening as files and folder, it doesnot have compilation unit, found very difficult to code using it.
What do I need to do inorder to make the source folder as java source folder so that I can code easily?
Select the project and from the context menu choose Maven -> Update Project Configuration (This menu item gets reworded across various maven releases so look for something similar). You may also need to choose Update Dependencies.
In the shell/command line, execute mvn eclipse:eclipse