3

I'm using Eclipse to work on a Spring project that is controlled via Maven (well, the m2e plugin in Eclipse).

Whenever I make a change to the Maven pom.xml file, the interface complains and says I subsequently need to run "Update project configuration" from the Maven item seen in the context menu when you right-click the top-level project.

When this completes, the project has then always lost its "Spring project nature", which I need to add again from the Spring item in the same context menu. This is quite annoying.

Why does it do this?

Is there any way to retain the Spring project nature permanently by adding something to the pom.xml?

Gangnus
  • 24,044
  • 16
  • 90
  • 149
Geeb
  • 631
  • 8
  • 19

1 Answers1

9

I use STS and do not have that problem, but I also have this plugin in my pom.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.7</version>  
    <configuration>
        <downloadSources>true</downloadSources>
        <downloadJavadocs>false</downloadJavadocs>
        <wtpversion>2.0</wtpversion>
        <additionalBuildcommands>
            <buildCommand>
                <name>org.springframework.ide.eclipse.core.springbuilder</name>
            </buildCommand>
        </additionalBuildcommands>
        <additionalProjectnatures>
            <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
        </additionalProjectnatures>
    </configuration>
</plugin>
Ralph
  • 118,862
  • 56
  • 287
  • 383
  • Thanks for your response. This is using the maven-eclipse-plugin. From the information I have gleaned so far from the Eclipse wiki [here](http://wiki.eclipse.org/M2E_FAQ#Maven_Integration_for_Eclipse_vs._Maven_eclipse:eclipse_plugin), I have fought shy of using this as I have chosen to use m2e to sort out my Maven stuff. It appears the two seem to "tread on one each others toes". Having said that the fact that a project nature can be defined in the pom.xml, as you have demonstrated, implies I need to include some similar tags to achieve my goal here. – Geeb Feb 03 '12 at 11:09
  • I think actually m2e has a different way of approaching "project nature" confinguration using the POM. See this other [stackoverflow question](http://stackoverflow.com/questions/4122308/can-i-configure-m2eclipse-through-pom-xml). Its still inconclusive as the author did not fully publish his solution, although an explanation was given. – Geeb Feb 03 '12 at 11:29
  • @Geeb: maybe, maybe not, that is why is stared with: "I do not have the problem" - and yes I am using m2e 1.0 too -- looks like some black magic -- So I would recommend to try what happens if you add the lines to your pom (without installing anything extra) -- if it does not work, I will delete this answer – Ralph Feb 03 '12 at 12:26
  • I tried it, and it worked! So thanks for that. The spring project nature was retained after an "update project configuration". Whats more if I manually remove the spring project nature in the IDE but leave your changes in the pom.xml the project nature is re-applied. P.S. I think you missed a closing `` tag from your XML snippet. – Geeb Feb 03 '12 at 14:30
  • closing tag (``) added – Ralph Feb 03 '12 at 14:37