Set up maven to download the source code of the jar package

1: Maven command to download source code and javadocs

When using Maven in the IDE, if you want to see the source code and javadoc of the classes in the referenced jar package, you need to download the source code through the maven command, and then import it. This purpose can be easily achieved through the mvn command:

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

Command usage: first enter the corresponding pom.xml directory, and then execute the above command:

 

The first command is to try to download the source code of the files that are depended on in pom.xml.

The second command: is to try to download the corresponding javadocs

But it is possible that some files do not have source code or javadocs

2: Add via configuration file

Open the maven configuration file setting.xml file (.../.m2/settings.xml) and add the following configuration:

<profiles>  
<profile>  
    <id>downloadSources</id>  
    <properties>  
        <downloadSources>true</downloadSources>  
        <downloadJavadocs>true</downloadJavadocs>             
    </properties>  
</profile>  
</profiles>  
  
<activeProfiles>  
  <activeProfile>downloadSources</activeProfile>  
</activeProfiles>

 

3: Configure eclipse

Window > Preferences > Maven and checking the "Download Artifact Sources" and "Download Artifact JavaDoc" options

 

Guess you like

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