4

I'm running tomcat as:

mvn tomcat7:run-war

I've found here that I can set parameters for debugging. By exporting maven option:

export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
mvn tomcat7:run-war

My first question, how can i connect to tomcat from IntelliJ IDEA? As usual I first configure tomcat itself in IDEA, but when I run it as embedded, there is no the application server at the moment I start it.

My second qustion, can I set MAVEN_OPTS in file, in order to skip running export command? I've read that in pom.xml it is impossible. But I found here that I can use the %HOMEDRIVE%%HOMEPATH%\mavenrc_pre.bat file for this purpose. But I cannot find anything about this file usage in my books about maven. Don't you know, does it work? In order to check it, first I need to resolve the first problem with connecting to tomcat from idea.

Community
  • 1
  • 1
Alexandr
  • 9,213
  • 12
  • 62
  • 102

1 Answers1

5

To connect to a tomcat from IDEA:

  • setup a "Remote" run configuration and specify the port you need to connect (here 8000)

enter image description here

ben75
  • 29,217
  • 10
  • 88
  • 134
  • 3
    As an alternative options, there is a way to debug Maven plugin goals from IDEA itself. Maven Projects tab -> Plugins -> tomcat7 -> tomcat7:run -> Debug – Alexandr May 02 '13 at 15:42
  • @Alexandr, I guess you mean tomcat7:run-war. Anyway this a neat solution that deserve to be posted as a separate answer. You got my vote anyway. – no id Feb 22 '17 at 11:47