在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
<build>
maven
<!-- 配置插件 -->
ui
<plugins>
this
<plugin>
插件
<groupId>org.apache.tomcat.maven</groupId>
code
<artifactId>tomcat7-maven-plugin</artifactId>
orm
<configuration>
xml
<!-- 门户服务端口号 -->
<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>