maven 下載 源碼和javadoc命令

1:Maven命令下載源碼和javadocs

當在IDE中使用Maven時若是想要看引用的jar包中類的源碼和javadoc須要經過maven命令下載這些源碼,而後再進行引入,經過mvn命令可以容易的達到這個目的:html

mvn dependency:sourcesjava

mvn dependency:resolve -Dclassifier=javadocapache

命令使用方法:首先進入到相應的pom.xml目錄中,而後執行以上命令:eclipse

第一個命令是嘗試下載在pom.xml中依賴的文件的源代碼。maven

第二個命令:是嘗試下載對應的javadocsui

可是有可能一些文件沒有源代碼或者javadocsspa


2:經過配置文件添加

打開maven配置文件 setting.xml文件(.../.m2/settings.xml) 增長以下配置:.net

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

<activeProfiles>
  <activeProfile>downloadSources</activeProfile>
</activeProfiles>


3:配置eclipse

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


轉者再補充一個方式,在pom.xml添加以下內容:

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>
    </build>

如下可做爲參考的相關連接:xml

http://www.blogjava.net/itspy/archive/2011/09/07/358233.html

http://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository

http://stackoverflow.com/questions/310720/get-source-jar-files-attached-to-eclipse-for-maven-managed-dependencies

相關文章
相關標籤/搜索