且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

What happened when we perform Maven Update Project in Eclipse

更新时间:2022-09-12 07:48:13

Created by Wang, Jerry, last modified on Jul 20, 2016

我们初始把project 从github copy下来时,project facet是空的,这可以解释,因为通过前面的分析,project facet信息时存放在.setting folder下面的那个文件里的,而那个文件没有上传到github上。当选择了Maven->Update project, Eclipse会解析pom.xml, 自动给该project 生成对应的project facet

如何分析的呢?

首先我把练习那个project的project facet改成只剩Javascript一个:

What happened when we perform Maven Update Project in EclipseApply之后发现Run as server的选项消失了:What happened when we perform Maven Update Project in Eclipse然后我做一次Maven update project,发现这里的help信息没啥帮助:What happened when we perform Maven Update Project in Eclipse然后我看到这个"Update project configuration from pom.xml", 觉得它有点关系,如何验证我的猜想?我先把这个勾去掉:What happened when we perform Maven Update Project in EclipseWhat happened when we perform Maven Update Project in Eclipse然后我再做一次,这次把这个勾选上:What happened when we perform Maven Update Project in Eclipse这次,发现所有的project facet都正确地determine出来了,印证了我的猜想。What happened when we perform Maven Update Project in EclipseFurther investigation needed

update应该还有其他用途,加载包之类的,经常import出错后,update就可以了。还有昨天pom文件正确加了plugin之后,就在文件开头报个错,也没得错误消息,一update就没问题了,也看不出哪里变了啥


早有人问了: http://***.com/questions/14992022/what-does-maven-update-project-exactly


http://***.com/questions/20546962/what-does-maven-update-project-do-in-eclipse


It syncs the Eclipse project settings with that of the pom. If you for example change important plugin settings, such as the output java version, you will find that Eclipse will ask you to update the project and afterwards the configured Java runtime in the project will have changed to reflect what your Maven pom indicates.


That is an important thing to keep in mind: the Maven pom is the lead in this kind of project setup. If you want settings to change, try to do that through the pom and not through Eclipse project settings directly or doing a project update might revert what you have changed. There are usually some things I have to correct myself anyway though, such as build path exclusions that m2eclipse likes to put in and strange deployment assembly configurations.