使用maven项目的NetBeans在附加到另一个应用程序中的jvm时不会单步执行代码

时间:2016-02-03 21:12:28

标签: java maven debugging netbeans

我第一次将NetBeans与Maven一起使用。 NetBeans中的一切都很好用。可以构建,打包安装等。可以调试和单步执行代码。当我尝试通过附加到链接JVM实例而不是NetBeans中的调试的另一个应用程序来调试我的代码时,问题就开始了。

我使用共享内存传输附加到进程并且成功。当我从该进程调用带有断点的java方法时,它会中断。我可以检查变量,我可以告诉它停在正确的位置,但它拒绝单步执行代码。 NetBeans并没有高亮显示它停止的行,并逐步执行代码,将netbeans引入一些Java内容,弹出Integer类,HashMap类等,并抱怨没有可用的源代码。然而,我可以在我的代码中设置另一个断点并点击继续。它会停在那里,但又不会再步了。

我的推测是它与我的类文件中的maven和不完整的调试信息有关。如果我重新配置我的项目使用ant一切正常,但回到maven再次搞砸了。

NetBeans中的“调试”视图显示"隐藏源调用":

enter image description here

有人有什么想法吗?感谢

我正在使用链接的jvm.dll启动我的应用程序,其中包含以下选项:

-Xdebug -Xrunjdwp:transport = dt_shmem,address = myexecutable,server = y,suspend = n

以下是我的示例pom文件:

http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

<groupId>com.some.company.edited</groupId>
<artifactId>atpg-parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<name>Parent Project</name>

<properties>
    <!-- Build Metadata -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- App & Platform Versions -->
    <java.target.version>1.7</java.target.version>
    <junit.version>4.12</junit.version>
    <!-- Build Plugin Versions -->
    <maven.compiler.plugin>3.2</maven.compiler.plugin>
</properties>

<modules>
    <module>atpg-main</module>
    <module>atpg-dm</module>
</modules>

<!-- Dependency VERSIONS -->
<dependencyManagement>
    <dependencies>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Shared Dependencies -->
<dependencies>
    <!-- Test Dependencies (can't hurt to include these all the time) -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>${maven.compiler.plugin}</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.target.version}</source>
                <target>${java.target.version}</target>
                <debug>true</debug>
                <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
    </plugins>
</build>

http://maven.apache.org/maven-v4_0_0.xsd">     4.0.0

<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-main</artifactId>
<packaging>jar</packaging>
<name>Main Project</name>

<dependencies>
    <!-- Project module dependencies -->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>atpg-dm</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

http://maven.apache.org/maven-v4_0_0.xsd">     4.0.0

<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-dm</artifactId>
<packaging>jar</packaging>
<name>Exchange Format Data Model</name>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <version>0.13.1</version>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

问题已解决。分辨率非常简单。事实证明,对于在NetBeans环境之外创建的Maven项目,不仅要打开父项目,还要打开项目中的所有模块。由于我的无知,我没有这样做。我只打开了父项目。

在打开的项目对话框中,实际上有一个复选框&#34;打开所需项目:&#34;它已经关闭了。一旦我检查了它,我的父母打开所有模块作为单独的项目,一切都很好。

因此,该问题与Java类文件中不完整的调试信息无关。默认情况下,此复选框处于关闭状态,这只是NetBeans的特性。