First, the application scenario
In order to use MAVEN's powerful package dependency management and project management capabilities, MAVEN2 is used as a project building tool in the project.
However, my project is built in the intranet, and in order to use MAVEN2, only the local warehouse dependency policy can be used.
However, there are times when the local warehouse does indeed have a corresponding dependency package, but in the eclipse environment will still error, that is: Pom.xml display error message.
Through my practice proved that can be solved by the following way.
Second, the example explanation
Take the dependency commons-io-2.0.1 as an example to explain:
Configure in Pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
Third, the solution
1, first, from other can download the corresponding dependency package in the external network to download the corresponding dependency package to the local warehouse, and then copy the local warehouse to the corresponding location of the project, easy to reference.
2, installation Maven2 and configuration, about Maven2 specific installation and configuration, skip.
Note: In Maven2 configuration file Setting.xml Be sure to modify the following properties:
<offline>true</offline>
This property is configured by default to False, because it is in the intranet and cannot be downloaded to the extranet dependency package, so be sure to configure the offline property to True.
3, if the local warehouse does exist the dependency package, and Eclipse does not error, then in the local warehouse to find the location of the dependency package, the corresponding directory must have the following 6 files:
_maven.repositories
Commons-io-2.0.1.jar
Commons-io-2.0.1.jar.sha1
Commons-io-2.0.1.pom
Commons-io-2.0.1.pom.sha1
M2e-lastupdated.properties
Figure 1 Dependency configuration is correct and Eclipse does not have an error when relying on files contained in the package directory
Of course, if the source code is downloaded, it should also include the following 2 files:
Commons-io-2.0.1-sources.jar
Commons-io-2.0.1-sources.jar.sha1
So, if the corresponding dependent jar package does exist in the local repository, but the error still occurs in eclipse, go to the directory location of the dependent package and see if there are 6 files in the directory as shown in Figure 1.
Typically, when an error occurs in Eclipse, a "xxx.lastupdated" file exists in the dependency package directory.
If the "xxx.lastupdated" file does exist, delete the file first. and confirm the existence of the following 2 files:
_maven.repositories
M2e-lastupdated.properties
Usually in eclipse error, there will be no such 2 files, to the other dependent on the correct jar directory to copy the 2 files into the current directory, and modify the corresponding content:
(1), modify "_maven.repositories" content:
#NOTE: A internal implementation file, its format can changed without prior notice.
#Wed Jul 09:16:30 CST 2013
${artifactid}-${version}-sources.jar>nexus=
${artifactid}-${version}. jar>central=
${artifactid}-${version}. pom>central=
${artifactid}-${version}. pom>nexus=
${artifactid}-${version}. jar>nexus=
For example: The contents of the _maven.repositories file in the commons-io-2.0.1 dependency package directory are as follows:
#NOTE: A internal implementation file, its format can changed without prior notice.
#Wed Jul 09:16:30 CST 2013
commons-io-2.0.1-sources.jar>nexus=
commons-io-2.0.1. jar>central=
commons-io-2.0.1. pom>central=
commons-io-2.0.1. pom>nexus=
commons-io-2.0.1. jar>nexus=
(2), m2e-lastupdated.properties file content can not be modified!
When you're done, clean up the project in Eclipse and execute "maven->update project ...", OK, problem solved!