Maven工程报错:No goals have been specified for this build. You must specify a valid lifecycle phase or a

来源:互联网 发布:树洞源码 编辑:程序博客网 时间:2024/05/20 19:31

在Maven工程中,启动服务时报出如下异常:

No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize,

其原因是在配置tomcat插件时编译出现了问题。给出如下代码就会报错异常信息:

<build><!-- 配置插件 --><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><!-- 门户服务端口号 --><port>8082</port><path>/</path></configuration></plugin></plugins></build>  

解决方法:eclipse安装的maven插件是m2eclipse,在控制台使用命令mvn compile并未报错。

需要修改pom.xml文件,在<build>标签里面加 上<defaultGoal>compile</defaultGoal>即可。

修改后的代码如下所示:

<build><defaultGoal>compile</defaultGoal><!-- 配置插件 --><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><configuration><!-- 门户服务端口号 --><port>8082</port><path>/</path></configuration></plugin></plugins></build>  


0 0