groovy入门()Groovy插件安装:Maven报Plugin execution not covered by lifecycle configuration

参考链接:http://www.cnblogs.com/rightmin/p/4945797.html

1、引入groovy的jar包

2、引入groovy编译插件

3、遇到问题 Plugin execution not covered by lifecycle configuration

4、解决办法

quickfix+删除重导入工程大法!!

下面是网上介绍的解决方法,下次遇到再试试:

5、附录代码 - eclipse开发Groovy代码,与java集成,maven打包编译

5.1、设置类路径 src/main/groovy

maven工程的java代码一般是这么放的 src/main/java/com.xxx.xxx

而我们的groovy的代码可以这么放,并把这个目录设置为classpath, src/main/groovy/com.xxx.xxx

5.2、测试程序HelloWorld.groovy

写一个hello world程序,创建的工程不是Groovy Project,所以这个文件eclipse是不认识的,会报错,不过只需要引入Groovy的相关jar就可以识别了

class AppGroovy {

static main(args) {
def closure = { param -> println "hello ${param}" }
closure("world")
}
}

5.3、引入pom依赖jar包

pmo.xml里面加入Groovy的引用

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.2-01</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.4.3-01</version>
</dependency>

5.4、引入pom依赖 编译插件

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.7.0-01</version>
</dependency>
</dependencies>
</plugin>

这样,上面那个Groovy类就可以被编译和识别了

5.5、编译运行

mvn package就可以打包进去了!!

运行方法:右键Groovy文件,Run As -> Groovy Sctipt

如果要嵌入Java类中也很简单,直接在java里面引用就好了

public class App {
public static void main(String[] args) {
AppGroovy.main(args);
}
}
运行方法:右键Java文件,Run As -> Java Application

时间: 2024-10-23 03:38:06

groovy入门()Groovy插件安装:Maven报Plugin execution not covered by lifecycle configuration的相关文章

解决Maven报Plugin execution not covered by lifecycle configuration

环境 eclipse 4.3.0 maven 3.0.4 m2e 1.4.0 出现场景 以前的老项目,在我的环境(我的环境较新)下,别人老环境不报错. 错误示例 一个错误示例,子项目引用了父项目,子项目parent标签处报错如下: Multiple annotations found at this line: - maven-enforcer-plugin (goal "enforce") is ignored by m2e. - Plugin execution not cover

解决Maven出现Plugin execution not covered by lifecycle configuration 错误

http://blog.163.com/xh_ding/blog/static/1939032892015222368827/ 解决Maven出现Plugin execution not covered by lifecycle configuration 错误

pom.xml报Plugin execution not covered by lifecycle configuration错误

环境 eclipse 4.3.0 maven 3.0.4 m2e 1.4.0 出现场景 以前的老项目,在我的环境(我的环境较新)下,别人老环境不报错. 错误示例 一个错误示例,子项目引用了父项目,子项目parent标签处报错如下: Multiple annotations found at this line: - maven-enforcer-plugin (goal "enforce") is ignored by m2e. - Plugin execution not cover

解决Maven报Plugin execution not covered by lifecycle

项目在老环境不报错,新环境报错. http://wiki.eclipse.org/M2E_plugin_execution_not_covered 在<plugins> 标签外再套一个 <pluginManagement> 标签 http://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin <bu

MyEclipse导入Maven项目报错 Plugin execution not covered by lifecycle configuration:

web项目使用到mybatis,需要使用mybatis的自动生成代码插件,配置build部分如下: 1 <build> 2 <pluginManagement></pluginManagement> 3 <plugins> 4 <plugin> 5 <artifactId>maven-war-plugin</artifactId> 6 </plugin> 7 <plugin> 8 <artif

Maven在导入其他项目时报错:Plugin execution not covered by lifecycle configuration

这几天想把Spring 攻略第二版完整的学习下,所以就在网上下载了该教材的源码,寻思边看书边练习!之前有过一些Maven开发的相关经验,觉得Maven在引入jar包上的配置还是很方便的,所以这次源码的Maven配置我倒是不担心,没想到项目导入后就报了一堆错误,一个一个的去解决,很多问题网上都有解决办法,就剩下一个问题折腾好久才解决掉,现将问题的解决过程记录如下: 1 问题描述 Plugin execution not covered by lifecycle configuration: org

在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”的解决方案

eclipse在其POM文件的一处提示出错如下: Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile) 这表示m2e在其执行maven的生命周期管理时没有定义该插件,所以提示出错,其实m2e对此是提供了扩展机制的,我们可以通过如下操

MAVEN “Plugin execution not covered by lifecycle configuration”

pom文件中报错提示: Plugin execution not covered by lifecycle configuration: net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress (execution: default, phase: process- resources) 上网一搜,很多人说在<plugins>标签外面加<pluginManagement>标签就可以了,加了pluginManageme

备忘:maven 错误信息: Plugin execution not covered by lifecycle configuration

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  <modelVers