[英]How to execute spring-boot:run from terminal for Remote Debugging
I'm trying to run the ./mvnw spring-boot:run
command so that I can do the remote debugging for that process.我正在尝试运行./mvnw spring-boot:run
命令,以便我可以对该进程进行远程调试。
I tried我试过
./mvnw exec:exec
-Dexec.executable="java"
-Dexec.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
spring-boot:run
I get the log Listening for transport dt_socket at address: 5005
我得到了Listening for transport dt_socket at address: 5005
的日志
But I get the error and maven process exits但是我收到错误并且 maven 进程退出
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) @ sample-project ---
Listening for transport dt_socket at address: 5005
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
[INFO] ------------------------------------------------------------------------
spring-boot:run
from terminal so that I can use it for Remote Debugging?如何从终端发送 execute spring-boot:run
以便我可以将其用于远程调试?Note I'm using Maven Wrapper for executing maven life cycle process, hence, I don't have access to
mvnDebug
注意我使用 Maven Wrapper 来执行 Maven 生命周期过程,因此,我无权访问mvnDebug
If you are already using spring-boot:run
in your project to run the application, then simply follow the instructions in the plugin's documentation for debugging the server....如果您已经在项目中使用spring-boot:run
来运行应用程序,那么只需按照插件文档中的说明来调试服务器....
https://docs.spring.io/spring-boot/docs/2.4.x/maven-plugin/reference/htmlsingle/#run-example-debug https://docs.spring.io/spring-boot/docs/2.4.x/maven-plugin/reference/htmlsingle/#run-example-debug
mvn spring-boot:run \
-Dspring-boot.run.jvmArguments="-Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
If you've got the spring-boot
plugin in your project, then just use the spring-boot.run.jvmArguments
property如果您的项目中有spring-boot
插件,那么只需使用spring-boot.run.jvmArguments
属性
If you're not already using the spring-boot plugin, then you shouldn't be passing spring-boot:run to Java.如果您还没有使用 spring-boot 插件,那么您不应该将 spring-boot:run 传递给 Java。 Java will know nothing about that. Java对此一无所知。 To run the jar from the command line, you use "java -jar "... so that will need to be reflected in the exec:exec command.要从命令行运行 jar,请使用“java -jar”...,因此需要在 exec:exec 命令中反映出来。 You need to, additionally, look at the exec plugin to see how to pass it jvm arguments (Which is what is needed to set up debugging).此外,您还需要查看 exec 插件以了解如何将其传递给 jvm 参数(这是设置调试所需的参数)。 Just using the spring-boot plugin is a bit easier.只需使用 spring-boot 插件就容易一些。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.