4

I use eclipse with maven integration for my java web application project. When you right click the project you can "refresh" the project. You can also use "maven -> update project". What is the difference between refresh and update?

Sometimes I got a red-x sign in my pom file (I don't think there is any error). When I use the "refresh", the red-x sign disappears. Any idea?

Another question is that when I update the project, in the property -> deployment assembly, the maven dependencies was removed (I manually added them when I created the project). How can I fix this?

Thanks

Zhuo
  • 99
  • 3
  • 10

2 Answers2

3

A quick google search yielded this result: What does Maven Update Project do in Eclipse?

The correct answer states:

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.

So in short,

  • Updating your project through maven synchronizes the settings with that of pom and keeps all the settings synchronized between the pom and the project.

  • Refreshing your project through eclipse will reload the project - that is reload all the files and apply any external changes from the files to the project.

Note that a maven update will cause a refresh of the project in eclipse.

Community
  • 1
  • 1
Luke Melaia
  • 1,470
  • 14
  • 22
0

FYI, here's what the official documentation states:

Refresh command

The official Eclipse Oxygen documentation has two distinct (yet similar) definitions:

Update Project command

Unfortunately, the only documented occurrence I have found in m2e documentation (see m2e 1.5 release notes) is utterly insufficient and barely related:

The Update Maven Project dialog (launched via Right-click project menu:Maven[Update Project…] or via kbd:[Alt-F5]), now shows a dirty overlay on projects which need updating.

Additionally, an “Add out-of-date” button adds all out-of-date (OOD) projects to the current selection. If an OOD project has not been selected, a warning is shown underneath the selection table with a link equivalent to “Add out-of-date”. Warning text and “Add out-of-date” button tooltip show a count of unselected OOD projects.


Related questions on the 'Update Project' command (or the 'Update Maven Project' dialog):

(Which, alas, however insightful the best answers are, still provide no official statement from m2e developers.)

KiriSakow
  • 957
  • 1
  • 12
  • 22