---
title: "maven2下载其源代码包并关联"
author: "east_java"
date: "2011-12-21T20:40:41Z"
tags: []
categories: ["企业架构"]
slug: "maven2"
draft: false
lastmod: "2011-12-21T20:40:41Z"
id: 1320003
url: "https://japi.iteye.com/blog/1320003"
---

使用maven下载jar包以及其源码包都很正常，但导入eclipse后，却发现在eclipse查看源码的时候并没有正常关联源码。

很是奇怪。

 

在个人机子上还是正常的，但公司机子却不能正常。

 

使maven2在下载依赖包的同时下载其源代码包的方法：

1\. 使用maven命令：mvn dependency:sources 下载依赖包的源代码。

2\. 使用参数： -DdownloadSources=true 下载源代码jar。 -DdownloadJavadocs=true 下载javadoc包。

mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true

 

**Eclipse**

mvn **-DdownloadSources=true** -DdownloadJavadocs=true -DoutputDirectory=target/eclipse-classes eclipse:eclipse

 

关键是红色标记选项~~