简体   繁体   中英

How to debug remote deployed spring boot app & maven on eclipse

I've deployed application on provider server on URL:

http://my.domain.net/my-spring-boot-app/

Provider use Tomcat as java app container. App connects to PostgreSQL, and it can do this only from this server host - because it is a restriction (probably on pg_conf). That it's important, because an error shows only on server site. How can I debug remotely my Spring Boot (war!) application, when I use maven & eclipse pack?

I don't know about the PostgreSQL issue but seems to me that this has nothing to do with data access layer or tools as it is basically a Java application which implies the rules for all JVM applications.

So in order to set up your server for remote debug, you have to hack the jvm (catalina in your case as you are running a Tomcat server) startup options by adding below entry to your startup script:

  • For a Windows system:

     set CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n %CATALINA_OPTS%" 
  • For a *nix system:

     export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n $CATALINA_OPTS" 

There is a shortcut to the below instruction, using the catalina startup script options, if that represents an alternative for you: catalina jpda start

You application is then up and listening on the configured port (8787 is this sample, which you must be open), and you can then attach your IDE ( Eclipse ) to debug the application remotely:

  • Navigate to Run -> Debug Configurations
  • Create a new Remote Java Application configuration
  • In the Connect tab setup the run configurations including the Host and Port
  • From the Common tab, check the Debug option.
  • Apply and Run you configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM