栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

IntelliJ IDEA 13 debugger don't stop on breakpoint in java for maven project

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

IntelliJ IDEA 13 debugger don't stop on breakpoint in java for maven project

My solution:

Considering that you have a program that depends on system properties:

package com.mycompany.app;public class App {    private static final String GREETING = System.getProperty("greeting", "Hi");    public static void main(String[] args) {        int x = 10;        System.out.println(GREETING);    }}

And you are running it with

exec:exec
:

mvn exec:exec -Dexec.executable=java "-Dexec.args=-classpath %classpath -Dgreeting="Hello" com.mycompany.app.App"

With some “inception magic” we can debug the process started by
Maven

exec:exec
.

Maven

Change your

exec:exec
goal to enable remote debugging. I’m using
suspend=y

and
server=n
, but feel free to configure the JDWP
Agent
as you please:

-agentlib:jdwp=transport=dt_socket,server=n,address=127.0.0.1:8000,suspend=y

This will not be passed directly to the maven JVM, instead it will be
passed to

exec.args
which will be used by
exec:exec
:

mvn exec:exec -Dexec.executable=java "-Dexec.args=-classpath %classpath -agentlib:jdwp=transport=dt_socket,server=n,address=127.0.0.1:8000,suspend=y -Dgreeting="Hello" com.mycompany.app.App"

IntelliJ IDEA

Create a

Remote
configuration (again I’m using a Listen strategy. You
should adjust it according to your process settings):

Now toggle your breakpoints and Debug your remote configuration. Using the
settings above it will wait until your process starts:

Finally run the

exec:exec
line above and debug your application at will:


So basically you need two “Run/Debug” configurations for this to work:

  1. A Maven configuration for
    exec:exec
    with the system properties and JDWP agent configuration:

  1. The remote configuration acting as a client.


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/430159.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号