使用带有IntelliJ的maven在tomcat中运行应用程序

Mat*_*ari 14 java tomcat intellij-idea maven

在不使用maven的情况下,要从Intellij IDE在tomcat上运行应用程序,您所要做的就是创建一个工件和指向该工件的"tomcat"运行配置,这样您就可以看到tomcat输出,重新启动服务器,以及其他东西在IDE中.

现在使用maven,不需要创建工件,因为maven已经进行了编译,打包等工作.

我知道我可以使用命令部署它,mvn tomcat7:redeploy但这样我就看不到标准输出/错误和调试.那么从IntelliJ运行应用程序而无需创建工件的标准方法是什么?

Nei*_*gan 8

pom.xml

<build>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <uriEncoding>UTF-8</uriEncoding>
                    <path>/your-path</path>
                    <update>true</update>
                </configuration>
            </plugin>
</build>
Run Code Online (Sandbox Code Playgroud)

在IntelliJ中,打开菜单>查看>工具窗口> Maven项目

Plugins > tomcat7 > tomcat7:run
Run Code Online (Sandbox Code Playgroud)


Ami*_*ila 6

如果你已经设定

<packaging>war</packaging>
Run Code Online (Sandbox Code Playgroud)

在您的pom中,IDEA应自动识别要部署的工件(您的WAR文件).无需手动创建工件.