当前位置:  开发笔记 > 编程语言 > 正文

使用Gradle预编译JSP

如何解决《使用Gradle预编译JSP》经验,为你挑选了0个好方法。

我试图将我们的构建过程从Maven改为Gradle(V 2.9).在Maven中我正在使用JSP的预编译:

        
            org.eclipse.jetty
            jetty-jspc-maven-plugin
            9.2.7.v20150116
            
                
                    package
                    jspc
                    
                        jspc
                    
                    
                        **\/*inc_page_bottom.jsp,**\/*inc_page_top.jsp
                        **\/*.jsp
                    
                
            
        

它工作正常.现在我试图找到一种方法来做同样的gradle.我找到了一些信息/ build.gradle示例,但没有什么工作真的.我目前使用Tomcat 7作为servlet容器,我计划在几周内切换到8.当然,为目标servlet容器编译它们当然是完美的但首先我很乐意预编译它们就像我这样做与maven为/与码头.

我当前build.gradle的一部分,它给了我一个错误:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.4'
    }
}

apply plugin: 'com.bmuschko.tomcat'

tomcat {
    jasper {
        validateXml = true
        errorOnUseBeanInvalidClassAttribute = false
        compilerSourceVM = "1.8"
        compilerTargetVM = "1.8"
    }
}

task compileJsps(type: JavaCompile, dependsOn: 'clean') {
    dependsOn tomcatJasper
    group = 'build'
    description = 'Translates and compiles JSPs'
    classpath = configurations.tomcat + sourceSets.main.output + sourceSets.main.runtimeClasspath
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
    destinationDir = file("$buildDir/jasper-classes")
    sourceSets {
        main {
            java {
                srcDir "$buildDir/jasper"
            }
        }
    }
}

dependencies {
    def tomcatVersion = '7.0.59'
    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
       "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
       "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
}

我收到以下错误:

:tomcatJasper FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':tomcatJasper'.
> org.apache.jasper.JasperException: file:/xxx/xxx/xxx/xxx/src/main/webapp/index.jsp (line: 6, column: 0) The value for the useBean class attribute xxx.xxx.xxx.XxxXxx is invalid.

在Tomcat 7中运行这个jsp工作得很好......有人有最新的howto或提示吗?

推荐阅读
mobiledu2402851377
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有