当在eclipse debug maven项目工程时,有时会出现 source not found情况。
有时候,可能进入源码页面,闪了一下就回到source not found 页面。

出现上述情况,请按下面步骤尝试操作:


【1】Tomcat 插件运行环境:

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>8080</port>
<server>tomcat7</server>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

【2】项目右键-debug as - debug configurations

Maven - debug as tomcat7:run提示source not found_运行环境


【3】选中左侧运行环境–点击右侧对应source

  • 此处的source即为运行环境关联的源码;
  • 默认有一个default–jdk的类库与maven的插件仓库;

Maven - debug as tomcat7:run提示source not found_debug_02

  • default 文件夹下关联的jar

Maven - debug as tomcat7:run提示source not found_debug_03


【4】根据需要,Add相应的源码

  • 这里根据需要,分为项目自身源码和框架、插件源码;

① 如下,添加项目自身源码:

  • Add - Project - 添加项目工程

Maven - debug as tomcat7:run提示source not found_maven_04

即可debug当前自身项目源码!!!


② 添加框架源码

  • Add - External Archive - 添加对应sources.jar

Maven - debug as tomcat7:run提示source not found_maven_05


添加完debug,仍不能关联第三方源码,请安装插件:

安装sourcelookup 插件:

http://ifedorenko.github.io/m2e-extras/

Tips:

如果添加后不成功,请尝试移除掉 default 文件夹!!