java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > maven项目没有Maven Dependencies

解决maven项目没有Maven Dependencies的问题

作者:svygh123

本文介绍了如何在Eclipse IDE for Enterprise Java Developers版本2019-12中配置Maven项目,通过新建项目、下载、导入等步骤,并解决了在JavaBuildPath中缺少MavenDependencies的问题

一、本文使用开发环境版本

注:

此eclipse版本已经内置maven插件,如果没有需要自行安装

二、新建项目

在start.spring.io配置了一个新的mave项目,下载到本地,导入到eclipse中

但是右键项目->Properties->Java Build Path->Libraries选项卡里并没有Maven Dependencies,

和以前的项目配置文件比较了一下,发现.classpath是这样配置

<?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"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
		<attributes>
			<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"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

就是缺少了

<attributes>
    <attribute name="maven.pomderived" value="true"/>
</attributes>

我们当然可以手动添加,但是理论上不应该手动添加,试着更新一下maven项目

右键项目->Maven->Update Project...

果然可以了

 截止本文完成,eclipse的版本如下

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文