Connect to embedded tomcat from IDEA

debugging, embedded-tomcat-7, intellij-idea, java, maven

Solution

To connect to a tomcat from IDEA:

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

Problem

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.

Original source

Related problems