Why must I always “Add Spring project Nature” after Maven “Update Project Configuration” in Eclipse?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 01:50:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!