指定的依赖项定义runtimeSpecified依赖项定义运行时(org.odftoolkit:odfdom-java-0.8.5)无效!跳绳

时间:2014-07-07 05:35:25

标签: grails dependencies

对于你的笔记,我是grails的新手。 我试图在我的项目中使用导出插件。 当我运行我的项目时,我得到这些依赖性错误"指定的依赖项定义运行时(org.odftoolkit:odfdom-java-0.8.5)无效!跳过.." 任何人都可以帮我摆脱这个错误PLZ? 这是我的域类代码:

class Book {     字符串作者     字符串标题     }

这是我的控制器代码:

import org.springframework.dao.DataIntegrityViolationException
class BookController {
def exportService
def grailsApplication  //inject GrailsApplication
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

def index() {
    redirect(action: "list", params: params)
}

def list(Integer max) {
    params.max = Math.min(max ?: 10, 100)
      if(!params.max) params.max = 10

    if(params?.format && params.format != "html"){
        response.contentType =      grailsApplication.config.grails.mime.types[params.format]
        response.setHeader("Content-disposition", "attachment; filename=books.${params.extension}")


        List fields = ["author", "title"]
        Map labels = ["author": "Author", "title": "Title"]


                    // Formatter closure
        def upperCase = { domain, value ->
            return value.toUpperCase()
        }

        Map formatters = [author: upperCase]        
        Map parameters = [title: "Cool books", "column.widths": [0.2, 0.3, 0.5]]

        exportService.export(params.format, response.outputStream, Book.list(params), fields, labels, formatters, parameters)
    }
            [bookInstanceList: Book.list(params), bookInstanceTotal: Book.count()]
}

def create() {
    [bookInstance: new Book(params)]
}

def save() {
    def bookInstance = new Book(params)
    if (!bookInstance.save(flush: true)) {
        render(view: "create", model: [bookInstance: bookInstance])
        return
    }

    flash.message = message(code: 'default.created.message', args: [message(code: 'book.label', default: 'Book'), bookInstance.id])
    redirect(action: "show", id: bookInstance.id)
}

def show(Long id) {
    def bookInstance = Book.get(id)
    if (!bookInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "list")
        return
    }

    [bookInstance: bookInstance]
}

def edit(Long id) {
    def bookInstance = Book.get(id)
    if (!bookInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "list")
        return
    }

    [bookInstance: bookInstance]
}

def update(Long id, Long version) {
    def bookInstance = Book.get(id)
    if (!bookInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "list")
        return
    }

    if (version != null) {
        if (bookInstance.version > version) {
            bookInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
                      [message(code: 'book.label', default: 'Book')] as Object[],
                      "Another user has updated this Book while you were editing")
            render(view: "edit", model: [bookInstance: bookInstance])
            return
        }
    }

    bookInstance.properties = params

    if (!bookInstance.save(flush: true)) {
        render(view: "edit", model: [bookInstance: bookInstance])
        return
    }

    flash.message = message(code: 'default.updated.message', args: [message(code: 'book.label', default: 'Book'), bookInstance.id])
    redirect(action: "show", id: bookInstance.id)
}

def delete(Long id) {
    def bookInstance = Book.get(id)
    if (!bookInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "list")
        return
    }

    try {
        bookInstance.delete(flush: true)
        flash.message = message(code: 'default.deleted.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "list")
    }
    catch (DataIntegrityViolationException e) {
        flash.message = message(code: 'default.not.deleted.message', args: [message(code: 'book.label', default: 'Book'), id])
        redirect(action: "show", id: id)
    }
}

}

构建配置:

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
//   run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]

grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
    // specify dependency exclusions here; for example, uncomment this to disable ehcache:
    // excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

repositories {
    inherits true // Whether to inherit repository definitions from plugins

    grailsPlugins()
    grailsHome()
    grailsCentral()

    mavenLocal()
    mavenCentral()

    // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
    //mavenRepo "http://snapshots.repository.codehaus.org"
    //mavenRepo "http://repository.codehaus.org"
    //mavenRepo "http://download.java.net/maven/2/"
    //mavenRepo "http://repository.jboss.com/maven2/"

mavenRepo" http://repo.grails.org/grails/core"
}

dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
    compile 'org.odftoolkit:odfdom-java-0.8.5'

    runtime 'org.odftoolkit:odfdom-java-0.8.5'

     // runtime 'mysql:mysql-connector-java:5.1.22'
}

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.8.3"
    runtime ":resources:1.2"

    // 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.5"

    build ":tomcat:$grailsVersion"

    runtime ":database-migration:1.3.2"

    compile ':cache:1.0.1'

    compile ":export:1.6"
        }

}

List.gsp:

<%@ page import="com.awnsys.Book" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main">
    <g:set var="entityName" value="${message(code: 'book.label', default: 'Book')}" />
    <title><g:message code="default.list.label" args="[entityName]" /></title>
    <r:require module="export"/>
    <export:resource />
</head>
<body>
    <a href="#list-book" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
    <div class="nav" role="navigation">
        <ul>
            <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
            <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
        </ul>
    </div>
    <div id="list-book" class="content scaffold-list" role="main">
        <h1><g:message code="default.list.label" args="[entityName]" /></h1>
        <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
        </g:if>
        <table>
            <thead>
                <tr>

                    <g:sortableColumn property="author" title="${message(code: 'book.author.label', default: 'Author')}" />

                    <g:sortableColumn property="title" title="${message(code: 'book.title.label', default: 'Title')}" />

                </tr>
            </thead>
            <tbody>
            <g:each in="${bookInstanceList}" status="i" var="bookInstance">
                <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">

                    <td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "author")}</g:link></td>

                    <td>${fieldValue(bean: bookInstance, field: "title")}</td>

                </tr>
            </g:each>
            </tbody>
        </table>
        <div class="pagination">
            <g:paginate total="${bookInstanceTotal}" />
        </div>
        <export:formats formats="['excel']" />
    </div>
</body>

2 个答案:

答案 0 :(得分:1)

这是依赖代码: 它工作正常。

repositories {
    mavenRepo "http://repo.grails.org/grails/core"
    }

dependencies {
    runtime 'org.apache.odftoolkit:odfdom'
}

答案 1 :(得分:0)

将依赖项添加到BuildConfig.groovy:

repositories {
    ...
    mavenRepo "http://repo.grails.org/grails/core"
}

dependencies { 
    ...
    compile 'org.odftoolkit:odfdom-java:0.8.5'
}