debugging 调试jHipster应用程序

7bsow1i6  于 2022-12-13  发布在  其他
关注(0)|答案(3)|浏览(219)

我是jHipster的新手,我已经创建了应用程序前端使用的API。我想调试我的服务,但无法使用IntelliJ附加调试器。
我的应用程序通过运行命令“mvnw”启动,这是jHispter标准命令,当我在编辑器中打开此bat文件时,我发现:

@REM例如,要调试Maven本身,请使用@REM设置MAVEN_OPTS=-Xdebug -Xrunjdwp:传输=dt_套接字,服务器=y,挂起=y,地址=8000

我设置了MAVEN_OPTS环境变量,但它仍然没有用。我还尝试在端口8000上从IDE进行远程连接,但它仍然没有任何作用。
任何帮助都将不胜感激,谢谢。

fjaof16o

fjaof16o1#

you can just run (in debug mode) the main method in the JhipApp Class (the SpringBootApplication Class). It worked for me

n3ipq98p

n3ipq98p2#

My tested and proven solution for debugging and then dividing the front end with the back ends, works for OS Windows and Ubuntu with the use of the latest version of the Ide Intellij Community (2020.1.1 used in both OS), provides that after creating a jhipster app (created with Ubuntu), from the command promp or from the Ubuntu shell launch the command: mvn -DskipTests = true clean install to compile the back end first and then the front end (in Angular 8 in my case), at the end of this compilation run the following command: mvn spring-boot: run. After launching the application, click Ctrl + C and stop the run. Now you can launch the npm commands and then the command: npm start from the same command prompt or from the shell, since your project has been built and already launched it will be restarted and now from the Ide you can launch your class configuration annotated with @SpringBootApplication from the debug icon, at the end of the compilation you will have front ends and back ends divided and debuggable easily as well as hot changes for the front end take place quickly, while for the back end you will always have to save recompile and restart in debug.

xbp102n0

xbp102n03#

You can do it, if you connect remotely, as you suggested in your question

  • Start jhipster in the terminal, but pass in some debug params
$ ./mvnw -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

Then you just connect to it using your IDE at port 5005.
For example, in Visual Studio Code

  • add a "launch.json" file
  • A "Add Configuration" button will be displayed when you have the launch.json as the active file in the editor. Click it.
  • Choose "Java: Attach by Process Id"
  • That will add a new configuration to the "Run and Debug" tab.
  • Click the "Attach by Process ID", button, and choose your process (port 5005 in this example)
  • Debugging will begin!

相关问题