Java 设置M2_回购类路径
我有几个与此相关的问题Java 设置M2_回购类路径,java,eclipse,maven,Java,Eclipse,Maven,我有几个与此相关的问题 什么是M2_回购 这个命令的作用是什么 mvn-Declipse.workspace=eclipse:addmaven repo 为什么我们需要做上述工作 M2_REPO是一个变量,用于定义maven 2存储库在磁盘上的位置 这意味着:将M2_REPO的定义添加到定义eclipse工作区的XML文件中 如果需要,可以手动执行相同的操作。这就是我个人所做的。只需转到Window/Preferences,然后选择Java/buildpath/Classpath变量。完成后,您
mvn-Declipse.workspace=eclipse:addmaven repo
这个答案是5年前写的。现在任何eclipse发行版都有maven插件,所以eclipse可以直接打开maven项目。添加到pom.xml中的每个依赖项都会自动下载,并且几乎可以立即使用 进入Windows->首选项->Java->构建路径->类路径变量->新建并添加以下内容 Name=M2_REPO(或者您为Maven存储库指定的名称)
Path=C:\Users\Administrator.m2\repository(我的保存在这里)不,您不希望所有maven工件都散落在eclipse项目/包资源管理器的库文件夹中 您希望所有maven工件都被很好地包装在 Java资源>库>Maven依赖项 就像过去一样 在您完成了其余答案中建议的一切之后,您所得到的仍然是将所有maven人工制品散落在pkg/prj explorer顶级列表的顶层,原因是您刚刚升级到最新和最棒的Eclipse版本,而您所拥有的m2eclipse插件版本尚未与该Eclipse版本同步 您也不希望运行mvn eclipse:eclipse或eclipse:config。。每次添加新的maven依赖项时。这完全违背了maven的主张 变通 当m2eclipse在黑暗中摸索你的全新eclipse版本时
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
去那里该怎么办?我应该单击NEW按钮,并设置哪些选项值。步骤2,哪个XML文件?