Tomcat在Intellij Idea社区版中

Vik*_*iia 61 java apache tomcat intellij-idea

是否可以在Intellij Idea Community Edition中使用Tomcat Server运行Web应用程序?

我试图找到一些有关它的信息,但没有取得任何成功.

use*_*610 31

Intellij社区不提供Java应用程序服务器集成.你的替代品是

  1. 购买Intellij许可证,
  2. 切换到Eclipse;)
  3. 安装Smart Tomcat插件https://plugins.jetbrains.com/plugin/9492
  4. 安装IDEA Jetty Runner插件https://plugins.jetbrains.com/plugin/7505
  5. 从Maven,Gradle等运行应用程序服务器,如其他答案中所述.

我个人安装了Jetty Runner插件(Jetty对我很好,我不需要Tomcat),我对这个解决方案很满意.我不得不处理IntelliJ的想法 - Jetty,报告异常.

  • Smart Tomcat插件也很方便. (3认同)

小智 23

如果您使用的是maven,则可以使用此命令mvn tomcat:run,但首先将pom.xml中的此结构添加到build标记中,如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

  • 我没有在IntelliJ IDEA 13.1版本的File-> Settings中看到"Application Server"选项.如何启用它. (8认同)
  • 如果你不使用Maven怎么办? (4认同)

Ale*_*sel 9

使用Maven,尝试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 Code Online (Sandbox Code Playgroud)

运行它 tomcat7:run-war

这里有更多目标


Ana*_*ika 6

Tomcat (Headless) 可以与 IntelliJ Idea - 社区版集成。

分步说明如下:

  1. 添加tomcatX-maven-plugin到 pom.xml

    <build>
        <plugins>
            <plugin>
                 <groupId>org.apache.tomcat.maven</groupId>
                 <artifactId>tomcat7-maven-plugin</artifactId>
                 <version>2.2</version>
                 <configuration>
                     <path>SampleProject</path>
                 </configuration>
            </plugin>
        </plugins>
    </build>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 添加新的运行配置如下:

    Run >> Edit Configurations >> + >> Maven
    
    Parameters tab ...
    Name :: Tomcat
    Working Directory :: Project Root Directory
    Command Line :: tomcat7:run
    
    Runner tab ...
    VM Options :: <user needed options>
    JRE :: <project needed>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 直接从 IntelliJ Run >> Run/Debug 菜单以 Run/Debug 模式调用 Tomcat

注意:虽然这被认为是使用 IntelliJ 的 Tomcat 集成功能 - 企业版功能的黑客攻击,但我认为这是一种将 tomcat 集成到 IntelliJ Idea - 社区版的编程方式。


Meo*_*Meo 5

是的,您可以使用maven插件或简单的Java程序。无需IDE插件。例如,请参见https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat中的 Main class