Maven工程报错:No goals have been specified for this

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

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

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

 

 
  1. <build>maven

  2. <!-- 配置插件 -->ui

  3. <plugins>this

  4. <plugin>插件

  5. <groupId>org.apache.tomcat.maven</groupId>code

  6. <artifactId>tomcat7-maven-plugin</artifactId>orm

  7. <configuration>xml

  8. <!-- 门户服务端口号 -->

  9. <port>8082</port>

  10. <path>/</path>

  11. </configuration>

  12. </plugin>

  13. </plugins>

  14. </build>


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

 

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

修改后的代码以下所示:

 

 
  1. <build>

  2. <defaultGoal>compile</defaultGoal>

  3. <!-- 配置插件 -->

  4. <plugins>

  5. <plugin>

  6. <groupId>org.apache.tomcat.maven</groupId>

  7. <artifactId>tomcat7-maven-plugin</artifactId>

  8. <configuration>

  9. <!-- 门户服务端口号 -->

  10. <port>8082</port>

  11. <path>/</path>

  12. </configuration>

  13. </plugin>

  14. </plugins>

  15. </build>

相关文章
相关标签/搜索