由于 Grails 没有从基于 pom.xml 文件的 Maven 存储库中选择 jar,我收到了一些编译错误。
我的 BuildConfig.groovy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
//excludes "grails-plugin-log4j"
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
//excludes "grails-plugin-log4j"
pom true
repositories {
inherits true // Whether to inherit repository definitions from plugins
//grailsPlugins()
/// grailsHome()
// grailsCentral()
mavenCentral()
mavenLocal()
// These are for the hudson machine
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
// mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.5'
compile 'org.apache.activemq:activemq-core:5.3.0'
test 'org.objenesis:objenesis:1.2'
compile 'org.slf4j:slf4j-log4j12:1.6.6'
//compile "spring-security-config:3.0.1.RELEASE"
}
plugins {
compile ":spring-security-core:1.2.7.3"
compile ":spring-security-ui:0.2"
compile ":jquery-ui:1.8.15"
compile ":jqgrid:3.8.0.1"
compile ":famfamfam:1.0.1"
compile ":mail:1.0"
compile ":jms:1.2"
compile ":calendar:1.2.1"
compile ':gpars:0.3'
compile ":lang-selector:0.3"
compile ":crypto:2.0"
compile ":grails-melody:1.13"
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
//runtime ":resources:1.1.6"
runtime ":resources:1.2.RC2"
runtime ":export:1.5"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
test ":spock:0.6"
}
}
我收到这样的错误:
Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 141 source files.
| Error Compilation error: startup failed:
/mycompany/dev/rmaddidev/wsmavenTest/pro/src/groovy/com/mycompany/rms/common/RMSExportService.groovy: 15: unable to resolve class org.xhtmlrenderer.pdf.ITextRenderer
@ line 15, column 1.
import org.xhtmlrenderer.pdf.ITextRenderer
^
1 error
ITextRenderer 类存在于我在 maven pom 中指定的 core-renderer.jar 中,如下所示。
如果我在 BuildConfig.groovy 中添加这些 jar,那么它工作正常。
compile 'org.xhtmlrenderer:core-renderer:R8'
compile 'com.lowagie:itext:2.0.8'
还有我的 Pom 文件:
<dependencies>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.8</version>
</dependency>