Tomcat in Intellij Idea Community Edition
Intellij Community does not offer Java application server integration. Your alternatives are
- buying Intellij licence,
- switching to Eclipse ;)
- installing Smart Tomcat plugin https://plugins.jetbrains.com/plugin/9492
- installing IDEA Jetty Runner plugin https://plugins.jetbrains.com/plugin/7505
- running the application server from Maven, Gradle, whatever, as outlined in the other answers.
I personally installed the Jetty Runner plugin (Jetty is fine for me, I do not need Tomcat) and I am satisfied with this solution. I had to deal with IntelliJ idea - Jetty, report an exception, though.
If you are using maven, you can use this command mvn tomcat:run
, but first you add in your pom.xml this structure into build tag, just like this:
<build> <finalName>mvn-webapp-test</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.compiler.plugin.version}</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>
Using Maven, try tomcat7-maven-plugin
:
<build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/</path> <contextFile>src/main/webapp/WEB-INF/config/app-config.xml</contextFile> <mode>context</mode> <charset>UTF-8</charset> <warDirectory>target/${project.artifactId}-${project.version}</warDirectory> </configuration> </plugin> </plugins> </build>
Run it using tomcat7:run-war
More goals here