There is no Maven Dependencies solution for projects in Eclipse

Keywords: Maven Eclipse Attribute Java

The Maven project in Eclipse should have a library called Maven Dependencies, as follows:

In the Configure Build Path interface, Maven Dependencies:

Sometimes the library disappears. It's useless to click Add Library in the Configure Build Path interface. I tried several times and failed to add it

There are two correct ways:

1. Right click on the project -- > Maven -- > Update Project

The Update Project function itself is used to update the project when the project structure changes, mainly to update the. classpath file, so that Eclipse processes the project according to the content of the latest. classpath file.

2. Directly change the. classpath file

Maven Dependencies this library is marked in the. classpath file as follows:

<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="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
	<attributes>
		<attribute name="maven.pomderived" value="true"/>
	 </attributes>
</classpathentry>

Add this section to the. Classpath file and put it under the < classpath > label, for example:

<?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 including="**/*.java" kind="src" path="src/main/resources"/>
	<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="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

That's all right.

Posted by rbrown on Sun, 05 Jan 2020 07:53:03 -0800