Nyle Hassan
Nyle Hassan

Reputation: 206

Debug jHipster application

I'm new to jHipster, I've created APIs which are consumed by my application's front end. I want to debug my services but unable to attach debugger with IntelliJ.

My application starts by running command "mvnw" which is jHispter standard command when I opened this bat file in editor i found this :

@REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

I setup MAVEN_OPTS environment variable but still it was of no use. I also tried to make a remote connection from IDE on port 8000 but still, it didn't serve a purpose.

Any help will be appreciated, thanks.

Upvotes: 5

Views: 7247

Answers (4)

geoffrey ritchey
geoffrey ritchey

Reputation: 1

In gradle you can add to the bootRun task and run with './gradlew =PX. Then connect remotely to port 5005 in this case.

bootRun {
    args = ["--spring.profiles.active=${springProfiles}"]
    if (project.hasProperty('X')) {
        jvmArgs = [
            "-Xdebug",
            "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
        ]
    }
}

Upvotes: 0

Brad Parks
Brad Parks

Reputation: 72293

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!

Upvotes: 2

Alex1988
Alex1988

Reputation: 21

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.

Upvotes: 1

theboss sam
theboss sam

Reputation: 11

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

Upvotes: 1

Related Questions