Unknown referenced nature: org.springframework.ide.eclipse.core.springnature - spring-tool-suite

In STS 4, my Java 10 Spring Boot 2.1 project warns me:
Unknown referenced nature:
org.springframework.ide.eclipse.core.springnature
How can I fix this?

Open the .project file in your source folder and comment/delete this line:
<nature>org.springframework.ide.eclipse.core.springnature</nature>

This is a left-over from a prior STS brought-in by the .project file due to a known issue.
To fix this, delete the project from your workspace(s) in STS, and remove the project meta-data from the file system:
rm .project
rm .classpath
rm .factorypath
rm -rf .settings
When you re-import the project, STS 4 will build proper project meta-data.

I saw this problem after installing Eclipse Jee-2019-03 and using it for a workspace created by Eclipse Oxygen.
My answer is similar to Amadán, but I did not see Spring in the right-click dropdown of the project... because I has not installed the Spring tools yet.
I did this:
Right-click on the project --> Properties --> Project Natures
click on springnature --> Remove
click Help --> Eclipse Marketplace...
Find: Spring --> click Go
on the Spring Tools 4 - for Spring Boot --> click Install
after that my project worked and I did not have to add springnature to the Project Natures

You might also try to just:
remove the Spring nature
right click on the project > Spring > Remove Spring Project Nature
add the Spring nature again
right click on the project > Spring > Add Spring Project Nature

Related

Spring JAR files not present in new Eclipse Spring project

I installed Spring in Eclipse/EE simply from the Eclipse Marketplace.
However, either the Spring jar files aren't there, or am missing something within the project setup.
I looked to find them in the project library thru "Build path". I even tried searching the .jar files within the Windows directories.
I know I'm missing something big-- please bear with me.
Took me hours.
Note: I saw stackoverflow.com/questions/6288563/adding-external-jar-file-in-eclipse/11004869.
Update: found the jars in an earlier release-- 3.05. OK now i think.
Of course they are not there. There is not reason for them to be in eclipse. Select File > New > Spring Template project. This will create new maven project with spring dependencies included

How to run Spring in Action Third Edition source code

I extracted sia3-code ZIP file and imported the extracted sia3-code folder as Existing Maven Projects in my Eclipse Helios IDE. It imported just fine but I don't see any of the src folder in the build path and I can't run the test classes.
This is how it looks:
Could someone help me with how to get the source code that comes along with the book running as maven project?
Thanks.
1] download the sourcecode into a dir, which i'll refer to as code_dir_tree
2] edit the pom.xml in the code_dir_tree root as follows:
replace:
<modules>
<module>translators</module>
</modules>
with:
<modules>
<module>knights</module>
<module>rest-client</module>
<module>springidol</module>
<module>springidol-annotation</module>
<module>springidol-aop</module>
<module>springidol-aspectj</module>
<module>springidol-atinject</module>
<module>springidol-autodiscovery</module>
<module>springidol-javaconfig</module>
<module>springidol-qualifiers</module>
</modules>
3] from a command shell in the code_dir_tree root directory, run: mvn eclipse:clean
4] within eclipse, ensure you have a refreshed, preferably empty workspace available
5] copy the entire code_dir_tree manually into the workspace - not the individual projects, the code_dir_tree itself.
6] in eclipse, perform import | existing maven projects, select the code_dir_tree root (already within the workspace),
ensure all the projects including the pom.xml are selected, hit finish
7] run maven updates, clean install builds - all -maven- projects aside from rest-client, which has an unresolved dependency,
should now be ready to go
The remaining projects, spitter and SpringPizza, are gradle projects - STS, which has gradle integraton, needs to be installed to get these imported
8] in eclipse, perform import | gradle project, select the spitter directory, hit ok, select 'build model', when complete ensure all are selected, hit finish
9] repeat the same process as in 8] for SpringPizza
That's it - you should be ready to roll!
In the package explorer, right-click on the java directory and select Build Path->Use as source folder. Do this for both java directories (the one in src/main and the one in src/tst).
Then right click on the project and select Configure->Convert to Maven project.
UPDATE:
I think you need to install the M2Eclipse Plugin. Here are some directions. Then you should be able to right click on your project and select Maven->Enable Dependency Management.
Since you are utilizing Spring, I would highly recommend you checkout SpringSource Tool Suite. It's Eclipse bundled with a lot of useful plugins (such as m2eclipse). Here's a brief snippet from their website:
The Spring Tool Suite™ (STS) provides the best Eclipse-powered development environment for building Spring-powered enterprise applications. STS supplies tools for all of the latest enterprise Java and Spring, and comes on top of the latest Eclipse releases.
Read about STS and download it at its site: http://www.springsource.org/sts
SECOND UPDATE:
I think I see what you did wrong. It looks like you specified the root of your project as the directory that contains the folder 'sia3-code'. That caused all the projects to be collapsed under one big project, which, I'm pretty sure, is not the way you want to do it.
Remove the project from your Eclipse. Then in the Package Explorer, right-click and select Import. Select "Existing Projects into Workspace". Select the root directory to be /your/path/to/sia3-code/ (do not select the root directory to be /your/path/to/). Then select Finish. You'll see that you have 10+ projects imported into your IDE.
The above steps were verified in STS, so you might need to adapt them a bit if you are using Eclipse Helios.

How to convert properly Eclipse project to Maven project?

I have created in Eclipse Dynamic Web Project. Then I have selected option 'Convert to Maven Project' from 'Configure' from right-click menu. And now I can see red errors on Java Resources folder in my project. But none subfolder is with red error. In which way can I resolve that problem? I am using Eclipse Juno and m2e plugin.
I have recognized that m2n plugin haven't created src/main/java, src/main/resources and src/main/webapp directories in Java Resources. But the error is still the same.
The process in manually. You need to create a pom.xml and change your folder structure to follow Mavens conventions. I would recommend to create a web project via maven archetypes and move your project step-by-step into the new structure.

How to add maven repository jars to eclipse buildpath?

From eclipse I can see all the necessary jars in maven repositories view. But I have around 100 errors for the missing jar files. So I have set M2_REPO environment variable. I have ran the mvn eclipse:eclipse command from command line. When I run this command an ear package is added to one of subpackages of my project. For example my project name is portal. And sub package is portal_ear. The ear after running mvn eclipse:eclipse command is added to target folder of portal_ear. So my question is as I have the jars already in the repository, how can I add those to the portal buildpath inside eclipse?
Thanks.
When you're using M2Eclipse, all you need to do is to make sure your Eclipse project is a Maven project. Select the project, click on "Convert > Convert to Maven project" or "Maven > Enable dependency management".
Do not manually add libraries. Also, the M2_REPO library variable is no longer used with m2eclipse, neither is to run the "mvn eclipse:eclipse" command. That is legacy you don't need to do any more.
You can also import your project by using "File > Import > Maven > Existing Maven project" and M2Eclipse will correctly set up the project's build path.
If you have custom Maven settings, such as an Enterprise Repository, you may want to tell M2Eclipse where to find your settings.xml file, if you do not have it in your user home but in the Maven installation (people do this sometimes). Go to "Window > Preferences > Maven > User Settings" and choose the right settings.xml.
Install m2e from the eclipse marketplace. You can now import existing maven projects into your workspace or convert existing ones.
Works very well for Eclipse 3.7
In my case, I had an existing project that was deployed in Eclipse fine. Thank you Mkyong: http://www.mkyong.com/spring-security/spring-security-hello-world-example/
But when I needed to add JSTL for Logout tag support, I didn't see how to add the the jstl.jar file that was just pulled into my repo as another M2_REPO/xyz configuration. Instead, I could only import it as you would a regular .jar file - and that didn't seem right to me.
After reading a bunch of posts without success, I decided to see if I could get around the Eclipse UI and update the project configuration manually. From the project I opened .classpath in a text editor and added a new entry for the jar file:
<classpathentry kind="var" path="M2_REPO/javax/servlet/jstl/1.2/jstl-1.2.jar" sourcepath="M2_REPO/javax/servlet/jstl/1.2/jstl-1.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
Then I just refreshed my project in Eclipse (no restart required) and ...
the JSTL build error I was having in my JSP page went away
the build path entry for JSTL was appearing with the same M2_REPO as the other entries
the deployed code worked fine in Tomcat
Yes a bit of a hack, but still relatively clean I think - cheers
Right click on the project --> Maven --> Update Project...
For me it worked simply like that

new maven POM file in eclipse java project

Have upgraded to eclipse.indigo using a new installation. Added m2e. Maven shows up under Windows>Preferences. File>New>Other>Maven gets the following options: Checkout ..., Maven Module, Maven Project. The Maven POM file option is missing. I'm trying to add Maven support to an existing Java project. Have read the manuals, searches, helps, etc. No explanation as to why the Add POM option is missing. Any idea how to get this option to appear?
In order to create a POM on your project, and also change the project structure to Maven default, right-click on your project > Configure > Convert to Maven Project.
Don't forget to choose the correct Packaging type (in your case I guess it will be POM).
I don't have this option either, seems to have disappeared with the latest version. This bug report seems to point in this direction as well:
https://issues.sonatype.org/browse/MNGECLIPSE-2709
The standard way should be to create a new Maven project through the wizard, which will then also contain a POM file. You could use that to create a dummy project and then copy over the POM file.
In most cases, I also just copy an existing POM file to the project and start with that.
Quick workaround: Adding a POM by hand. (Also I'm not sure that I've ever seen an "Add POM" option.)
Simply add a file to your project (New > General > File), and name it pom.xml. On double-click on this file, the POM Editor will open.