首页 文章

无法解析groovy.text.XmlTemplateEngine

提问于
浏览
0

尝试在我的基于Maven的项目的基于Groovy的单元测试中使用groovy.text.XmlTemplateEngine,并使用gmaven插件配置如下

<plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.5-jenkins-3</version>
        <dependencies>
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>2.4.12</version>
            </dependency>
        </dependencies>
      </plugin>

我的命令行build mvn clean install 无法使用错误消息编译我的简单Groovy单元测试文件

[ERROR]文件:/ Users /../ my-service / src / test / groovy / myapp / MyApplicationTest.groovy:84:无法解析类groovy.text.XmlTemplateEngine [ERROR] @第84行,第30列 . [错误] XmlTemplateEngine engine = new groovy.text.XmlTemplateEngine()[ERROR] ^

在文件中我只是做一个简单的命令

import groovy.text.XmlTemplateEngine
...
XmlTemplateEngine engine = new groovy.text.XmlTemplateEngine()

两行都失败并显示相同的错误消息 . 我的OSX命令行中安装的Groovy版本是2.4.12 .

1 回答

  • 0

    我分析了输出

    mvn -e -X test
    

    命令和didn 't find the groovy-all.jar on the classpath during the test compilation phase. Only groovy.jar was present and it doesn' t包含 groovy.text.XmlTemplateEngine 类 .

    所以,我添加了一个额外的测试依赖:

    <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.12</version>
            <scope>test</scope>
        </dependency>
    

    它现在很好地编译了我的测试 .

相关问题