Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

java - Setting up M2_REPO classpath

I have a few questions corresponding to this.

  1. What is M2_REPO?
  2. What does this command do?

    mvn -Declipse.workspace=<your_workspace_location> eclipse:add-maven-repo

  3. Why do we need to do the above?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. M2_REPO is a variable that defines where maven 2 repository is on your disk
  2. This means: add definition of M2_REPO to XML file that defines the eclipse workspace
  3. You can do the same manually if you want. That is what I personally did. Just go to Window/Preferences and then choose Java/Build Path/Classpath Variables. Once you did it you can enjoy maven integration with eclipse. Every time you add new dependency to your pom.xml, run

    mvn eclipse:eclipse

and refresh you workspace you get all new libraries into classpath of your project.

EDIT

This answer was written 5 years ago. These days any eclipse distribution has maven plugin, so eclipse can open maven project directly. Every dependency you add to your pom.xml is automatically downloaded and almost immediately ready to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...