我正在使用jassper jspc gradle plugin我要预编译所有jsps"在build"上,配置注意文档:
buildscript {
repositories {
[...]
maven {
url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
dependencies {
[...]
"com.liferay.gradle.plugins.jasper.jspc", version: "2.0.1"
}
}
[...]
apply plugin: "com.liferay.jasper.jspc"
当我执行" gradle task"我可以看到插件任务已创建:
Verification tasks
------------------
check - Runs all checks.
compileJSP - Compile JSP files to check for errors.
test - Runs the unit tests.
但如果我执行其中一项任务,例如gradle compileJSP,我会得到同样的错误:
:project-web:generateJSPJava
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.liferay.jasper.jspc.JspC.main(JspC.java:52)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.jasper.jspc.JspC._runWithClassPath(JspC.java:168)
at com.liferay.jasper.jspc.JspC.main(JspC.java:46)
Caused by: java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
at org.apache.jasper.compiler.JspUtil.getExpressionFactory(JspUtil.java:1192)
at org.apache.jasper.compiler.JspUtil.validateExpressions(JspUtil.java:654)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1366)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1142)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:859)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1502)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2347)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2353)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:499)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2297)
at org.apache.jasper.compiler.Validator.validate(Validator.java:1890)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:223)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.JspC.processFile(JspC.java:1178)
at org.apache.jasper.JspC.execute(JspC.java:1345)
... 6 more
:project-web:generateJSPJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':project-web:generateJSPJava'.
> Process 'command '/home/[...]/.sdkman/candidates/java/8u121/bin/java'' finished with non-zero exit value 1
任何想法或替代解决方案?
答案 0 :(得分:1)
您在运行时使用的javax.el.ExpressionFactory
版本似乎与编译javax.el.ExpressionFactory
插件的jasper.jspc
版本不同。
我在javax.el.ExpressionFactory
的maven中心做了一个jar搜索here。也许您可以使用gradle dependencyInsight
来查看类版本更改的原因。
如果您想查看课程所在的位置,可以将其添加到您的版本中。
task printExpressionFactoryLocations {
doLast {
String findMe = 'javax/el/ExpressionFactory.class'
def configuration = buildscript.configurations.classpath
def jars = configuration.asFileTree.matching {
include '*.jar'
}
jars.files.each { File jar ->
def entries = zipTree(jar).matching {
include findMe
}
if (!entries.files.empty) {
println "Found $findMe in $jar.name"
}
}
}
}
答案 1 :(得分:0)
这个插件最终不再有用了。此外,没有人使用它(检查maven回购使用)