Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify a module I want to debug in a maven project #1294

Closed
pigbayspy opened this issue Feb 28, 2024 · 3 comments
Closed

How to specify a module I want to debug in a maven project #1294

pigbayspy opened this issue Feb 28, 2024 · 3 comments

Comments

@pigbayspy
Copy link

pigbayspy commented Feb 28, 2024

Hi there. Here is my maven project structure. fcs-common is a common module which included the shared main class, and other modules depend on the module fcs-common. fcs-aids-service, fcs-trs-service and such on other modules is microservice in Spring Boot framework.

project

  • fcs-common
  • fcs-aids-service
  • fcs-trs-service
  • fcs-xxx-service
  • ...

I try to launch my fcs-trs-service, and here is my launch.json.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "fcs-trs-service",
            "request": "launch",
            "mainClass": "com.hihonor.zeus.loader.ZeusAppMain",
            "sourcePaths": [
                "${workspaceFolder}/fcs-trs-service",
                "${workspaceFolder}/fcs-common"
            ],
            "vmArgs": [
                "-DserviceName=fcs-trs-service",
                "-Dspring.profiles.active=beta"
            ],
            "shortenCommandLine": "jarmanifest",
        }
    ]
}

Actually, I found that the fcs-aids-service was launched, and here is the command line:

& 'D:\jdk8\bin\java.exe' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:53232' '-DserviceName=fcs-trs-service' '-Dspring.profiles.active=beta' '-cp' 'C:\Users\Y00017~1\AppData\Local\Temp\cp_8y8tqxdwz2j16d0int33yh8aa.jar' 'com.hihonor.zeus.loader.ZeusAppMain'

I tried to unzip the temporary jar package cp_8y8tqxdwz2j16d0int33yh8aa.jar,and the META-INF/MANIFEST.MF showed that its classpath included fcs-aids-service/target/classes/ and fcs-common/target/classes/.

So, I guess that the java debugger launched the fcs-aids-service module in default lexicographic order, and I need use other configurations to specify the module that I want to launch.

@jdneo
Copy link
Member

jdneo commented Mar 6, 2024

Add @testforstephen

@testforstephen
Copy link
Contributor

@pigbayspy I don't understand what's your issue. Could you provide a specific project and steps for us to reproduce the problem? This would be very helpful.

Regarding the launching behavior, Java Debugger typically uses the mainClass as the entry point and locates the project that contains the main class. It then calculates the classpaths of the containing project, which includes the project’s source path and all its dependencies. These classpaths are then added to the final command line as the -cp parameter.

@pigbayspy
Copy link
Author

I found that I could use "projectName" parameter to specify the module which I want to launch.
Please close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants