(Quick Reference)

3.7.9 Maven集成 - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

3.7.9 Maven集成

When using the Grails Maven plugin, Grails' dependency resolution mechanics are disabled as it is assumed that you will manage dependencies with Maven's pom.xml file.

However, if you would like to continue using Grails regular commands like run-app, test-app and so on then you can tell Grails' command line to load dependencies from the Maven pom.xml file instead.

To do so simply add the following line to your BuildConfig.groovy:

grails.project.dependency.resolution = {
    pom true
    ..
}

The line pom true tells Grails to parse Maven's pom.xml and load dependencies from there.

当使用Grails的Maven插件时,Grails自带的依赖解析机制将被禁止,因为其假设你已经使用Maven的pom.xml来管理依赖了。

即使这样,你如果想继续使用Grails的常规命令比如run-apptest-app等等,你还是可以通过其命令行从Maven的pom.xml加载依赖的。

你只需要在BuildConfig.groovy文件中简单加入如下即可:

grails.project.dependency.resolution = {
    pom true
    ..
}

pom true就是用来告诉Grails要使用Maven的pom.xml来加载依赖。