问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/9115171/why-must-i-always-add-spring-project-nature-after-maven-update-project-config