idea中开发javaweb应用,使用mvn tomcat7:run命令运行应用时,需要配置tomcat的maven插件。在没有配置的情况下会出现下面的错误提示。
[ERROR] No plugin found for prefix ‘tomcat7’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Administrator.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
添加tomcat的maven插件配置即可。
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/${project.artifactId}</path>
</configuration>
</plugin>
不过要注意的是,就算配置正确,若web应用的工作目录(Working directory)配置错误的话,还是会存在这个错误。
还有一点需要补充说明一下,不管机器中安装的tomcat版本是7还是8,都可以使用这个插件来运行应用。使用这种方法,不仅修改的jsp可以立即生效,也可以实现类的热部署,还可以使用断点调试。强大的idea。