【发布时间】:2016-03-25 01:46:19
【问题描述】:
我试图将我们的构建过程从 Maven 更改为 Gradle (V 2.9)。在 Maven 中,我像这样为 JSP 使用预编译:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>9.2.7.v20150116</version>
<executions>
<execution>
<phase>package</phase>
<id>jspc</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<excludes>**\/*inc_page_bottom.jsp,**\/*inc_page_top.jsp</excludes>
<includes>**\/*.jsp</includes>
</configuration>
</execution>
</executions>
</plugin>
它工作正常。 现在我试图找到一种方法来对 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 可以正常工作... 有人有最新的操作方法或提示吗?
【问题讨论】:
-
曾经得到过这个问题的答案吗?我在 Maven 中看到了同样的问题,其中 在服务器上工作但不在预编译上下文中
-
很遗憾,没有(我自己也没有找到任何解决方案......)
-
我们也放弃了支持提升 jetty 的 jdt-core 以获得与 jre 18u112 兼容的 jasper 编译器
标签: jsp gradle tomcat7 precompile