【问题标题】:grails rest-api app error in deploying tomcat部署tomcat时grails rest-api应用程序错误
【发布时间】:2020-12-16 17:20:13
【问题描述】:

我在使用 grails 中的 rest-api 配置文件时遇到问题,将战争部署到 tomcat-server 时,我得到 500: 无法解析名称为“grailsDispatcherServlet”的 servlet 中名称为“/error”的视图

一切都在使用嵌入式 tomcat。

这是我的 build.gradle

buildscript {
    repositories {
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:7.0.4"
        classpath "org.grails.plugins:views-gradle:2.0.2"

//        classpath "org.grails.plugins:db-reverse-engineer:4.0.0"
    } }

version "0.1" group "myapp"

apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" apply plugin:"org.grails.plugins.views-json"

repositories {
    maven { url "https://repo.grails.org/grails/core" } }

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    } }

dependencies {
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    //provided "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-codecs"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-datasource"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.4.18.Final"
    compile "org.grails.plugins:views-json"
    compile "org.grails.plugins:views-json-templates"
    compileOnly "io.micronaut:micronaut-inject-groovy"
    console "org.grails:grails-console"
    profile "org.grails.profiles:rest-api"
    runtime "org.glassfish.web:el-impl:2.1.2-b03"

    runtime 'net.sourceforge.jtds:jtds:1.3.1'

    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "javax.xml.bind:jaxb-api:2.3.1"
    testCompile "io.micronaut:micronaut-inject-groovy"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.mockito:mockito-core"
    testCompile "io.micronaut:micronaut-http-client"
    testCompile "org.grails:grails-web-testing-support"
    testCompile "org.grails:views-json-testing-support"
    testCompile "org.hibernate.validator:hibernate-validator:6.0.20.Final"

//    compile 'org.grails.plugins:db-reverse-engineer:4.0.0' //    compile "org.grails.plugins:converters:4.0.1" }

bootRun {
    ignoreExitValue true
    jvmArgs(
        '-Dspring.output.ansi.enabled=always', 
        '-noverify', 
        '-XX:TieredStopAtLevel=1',
        '-Xmx1024m')
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
    //sourceResources sourceSets.main }

tasks.withType(GroovyCompile) {
    configure(groovyOptions) {
        forkOptions.jvmArgs = ['-Xmx1024m']
    } }

UrlMappippings.groovy

class UrlMappings {

    static mappings = {

        get "/articoli"(controller:"art", action:"index")

        //"/"(controller: 'application', action:'index')
        "500"(view: '/error')
        "404"(view: '/notFound')
        "400"(view: '/badRequest')
    }
}

Tomcat9,grails 4.0.5。 有什么建议? 提前致谢。问候

【问题讨论】:

    标签: rest grails


    【解决方案1】:

    已通过使用新版本的 Grails Views (2.0.3) 解决。

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 1970-01-01
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多