gpt4 book ai didi

java - Gradle Tomcat 插件依赖

转载 作者:行者123 更新时间:2023-11-28 22:55:47 24 4
gpt4 key购买 nike

也许我没有正确理解 Gradle 的配置,但我似乎无法理解这里发生的事情。我的 WAR 中需要 org.glassfish.web:javax.servlet.jsp.jSTL:1.2.1 因为 Tomcat 不提供 JSTL,所以我将依赖项放在运行时配置上(编译不需要)。 tomcat配置也需要这个包。但是,只有将依赖项添加到 tomcat 配置中,tomcatRun 任务才会起作用。如果将依赖项添加到运行时,或同时添加到运行时和 tomcat,或两者都不添加,则以下堆栈跟踪结果:

Servlet  threw load() exception
org.apache.jasper.JasperException: /WEB-INF/jsp/index.jsp (line: 1, column: 63) Unable to read TLD "META-INF/c.tld" from JAR file "file:/home/rob/.gradle/caches/modules-2/files-2.1/org.glassfish.web/javax.servlet.jsp.jstl/1.2.1/7f687140e9d264ee00eaa924714adf9a82cc18dc/javax.servlet.jsp.jstl-1.2.1.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:219)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:184)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1410)
at org.apache.jasper.compiler.Parser.parse(Parser.java:138)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:138)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5231)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5518)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

gradle代码如下。有问题的行被注释掉,允许 tomcatRun 成功运行但阻止我的 WAR 运行。当取消注释该行时,tomcatRun 失败并且 WAR 工作。

dependencies {
runtime 'org.apache.derby:derby:10.10.2.0',
'com.sun.mail:javax.mail:1.5.2'/*,
'org.glassfish.web:javax.servlet.jsp.jstl:1.2.1'*/

compile 'javax.mail:javax.mail-api:1.5.2'

providedCompile "javax.servlet:javax.servlet-api:${servletSpec}"

tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
"org.apache.tomcat:tomcat-dbcp:${tomcatVersion}",
files('ecj-4.3.1.jar'),
"org.glassfish.web:javax.servlet.jsp.jstl:1.2.1"

tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}

最佳答案

请使用https://mvnrepository.com/artifact/javax.servlet/jstl/1.2

compile group: 'javax.servlet', name: 'jstl', version: '1.2'

我用过https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl并得到同样的错误。

关于java - Gradle Tomcat 插件依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27553341/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com