Java 调试Maven依赖项
项目“child”包含一个java类:Java 调试Maven依赖项,java,maven,debugging,Java,Maven,Debugging,项目“child”包含一个java类: package org.child; public class Elaborate { public String getStr() { return "hello"; } } import org.child.Elaborate; public class App { public static void main(String[] args) { Elaborate elaborate = new
package org.child;
public class Elaborate {
public String getStr() {
return "hello";
}
}
import org.child.Elaborate;
public class App {
public static void main(String[] args) {
Elaborate elaborate = new Elaborate();
System.out.println(elaborate.getStr());
}
}
这个pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.child</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.child</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
这个pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.child</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.child</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
4.0.0
org.parent
父母亲
1.0-快照
org.child
小孩
1.0-快照
我正在将这两个项目打开到两个单独的Intellij窗口中。我要做的是在两侧进行调试
但是,如果使用“父级”运行应用程序,则只能调试父级。如果我在“child”中设置断点,调试器不会停止
你知道我该怎么做吗?我和你有同样的问题,我想: 我有多个maven包,它们是独立的IntelliJ“模块” 为了调试maven“依赖项”,将其作为“模块”加载到IntelliJ“项目”主窗口中 文件>项目结构…>项目设置>模块 添加>导入模块 现在导航到以前安装的maven包,并选择该文件夹 从外部模块>Maven中选择导入模块 并确保选择了“自动导入Maven项目”
您现在应该在项目的侧栏中看到两个“模块”。在其中一个依赖项模块中设置断点,然后运行>调试主模块,该模块应按预期工作。使用依赖项调试需要源代码。我不知道IntelliJ的情况,但我想这个过程是一样的。您需要告诉IntelliJ哪些源文件对应于“child”,然后才能放置断点。您是否尝试过在同一IntelliJ的同一工作区中打开两个项目?让IntellijMaven插件来确定子模块是否是父依赖项的源。我猜这就像在EclipseAttach调试器图标中,然后选择process.when导入带有maven的代码时,它会下载到用户目录/.m2