Build dependencies for code with Maven

Using Maven to manage the dependencies of the code is a good way. The dependencies and downloads of the jar packages are all done by Maven for us, which is very convenient.

 

The main steps to build a dependency package with Maven:

1. Double click Pom.xml

In the Dependencies tab click add,

After entering the corresponding information, click OK



 

 

2. Switch to Dependencies Hierarchy and you will find that the dependencies of json-lib are automatically downloaded



 

 

 

3. Click Add Library in the build path of the project, select Maven Managed Dependencies, the next step,

Click on Maven Project Setting and fill in the library name Maven Dependencies in Active Maven Profiles

 

4. In the run mode, select Maven Install to add the Maven Dependencies class library to the project's dependency class library

 

 

The following is a personal summary of the points that need to be paid attention to when using Maven to compile projects in Eclipse:

 

1. Execution default-testResources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:testResources failed

solution:

Because there is no maven-resources-plugin: 2.4.3 in the plugin, you need to remove the check in Eclipse->Window->Preferences -> maven -> offline

 

2. Specify the absolute path to Maven setting.xml

Eclipse->Window->Preferences -> maven -> User Settings Specify the file MAVEN_HOME/conf/settings.xml

 

3. Configure the remote warehouse in setting.xml

<mirrors></mirrors> added

<mirror> 
          <id>central_mirror</id> 
          <name>internal central_mirror epository</name> 
          <url>http://repo1.maven.org/maven2/</url>
          <mirrorOf>central</mirrorOf>   
  </mirror>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326370031&siteId=291194637