Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
763 views
in Technique[技术] by (71.8m points)

websphere - How can I start an Open Liberty server in debug mode with the liberty-maven-plugin "run" goal?

The liberty:run goal of the liberty-maven-plugin provides a single goal to create a server, install needed features and deploy my app, but what if I want to attach a debugger to step through my application?

The liberty:debug goal isn't the answer since it doesn't perform all these actions in a single goal.

question from:https://stackoverflow.com/questions/65893511/how-can-i-start-an-open-liberty-server-in-debug-mode-with-the-liberty-maven-plug

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For recent versions (since v3.1) of the liberty-maven-plugin, like:

        <plugin>
            <groupId>io.openliberty.tools</groupId>
            <artifactId>liberty-maven-plugin</artifactId>
            <version>3.3.3</version>
        </plugin>

there are a couple options:

1. Add a -Dliberty.jvm.debug property

(using "run" as the OP asked about)

$ mvn liberty:run -Dliberty.jvm.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777"

Note the 'debug' part of the 'liberty.jvm.debug' property name can be any string.

2. Use the liberty:dev mode (goal) instead

(an even better, richer approach)

The 'dev' goal will also install an Open Liberty server in the foreground, and deploy your app to it, (like 'run'), while also creating a file "watcher" to detect project changes, upon which it will automatically update your installation, rebuild and redeploy your app, and rerun your tests. (And you can attach the debugger by default).

For more information see:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...