我正在尝试在我的Maven项目中实现Wro4j。

我在pom.xml中添加了以下代码依赖项:

<properties>
    <wro4j.version>1.7.9</wro4j.version>
</properties>
<dependency>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-core</artifactId>
    <version>${wro4j.version}</version>
</dependency>
<dependency>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-extensions</artifactId>
    <version>${wro4j.version}</version>
</dependency>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>envjs</artifactId>
    <version>1.2</version>
</dependency>
<dependency>
    <groupId>org.mozilla</groupId>
    <artifactId>rhino</artifactId>
    <version>1.7R4</version>
</dependency>


这是出现的错误:

7:26:58,396 ERROR [LessCss] Processing error:Couldn't initialize env.rhino script
java.lang.RuntimeException: Couldn't initialize env.rhino script
    at ro.isdc.wro.extensions.script.RhinoScriptBuilder.addClientSideEnvironment(RhinoScriptBuilder.java:96)
    at ro.isdc.wro.extensions.script.RhinoScriptBuilder.newClientSideAwareChain(RhinoScriptBuilder.java:233)
    at ro.isdc.wro.extensions.processor.support.less.LessCss.initScriptBuilder(LessCss.java:45)
    at ro.isdc.wro.extensions.processor.support.less.LessCss.less(LessCss.java:84)
    at ro.isdc.wro.extensions.processor.css.RhinoLessCssProcessor.process(RhinoLessCssProcessor.java:130)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.LazyProcessorDecorator.process(LazyProcessorDecorator.java:49)
    at ro.isdc.wro.extensions.processor.js.AbstractNodeWithFallbackProcessor.process(AbstractNodeWithFallbackProcessor.java:59)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.SupportAwareProcessorDecorator.process(SupportAwareProcessorDecorator.java:39)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.ExceptionHandlingProcessorDecorator.process(ExceptionHandlingProcessorDecorator.java:56)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.BenchmarkProcessorDecorator.process(BenchmarkProcessorDecorator.java:44)
    at ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator.process(ProcessorDecorator.java:86)
    at ro.isdc.wro.model.resource.processor.decorator.DefaultProcessorDecorator.process(DefaultProcessorDecorator.java:42)
    at ro.isdc.wro.model.group.processor.PreProcessorExecutor$2.process(PreProcessorExecutor.java:228)
    at ro.isdc.wro.model.group.processor.PreProcessorExecutor.applyPreProcessors(PreProcessorExecutor.java:207)
    at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:103)
    at ro.isdc.wro.model.group.processor.PreProcessorExecutor.processAndMerge(PreProcessorExecutor.java:77)
    at ro.isdc.wro.model.group.processor.GroupsProcessor.process(GroupsProcessor.java:83)
    at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:101)
    at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:35)
    at ro.isdc.wro.cache.support.AbstractSynchronizedCacheStrategyDecorator.get(AbstractSynchronizedCacheStrategyDecorator.java:55)
    at ro.isdc.wro.manager.ResourceBundleProcessor.serveProcessedBundle(ResourceBundleProcessor.java:63)
    at ro.isdc.wro.manager.WroManager.process(WroManager.java:159)
    at ro.isdc.wro.http.WroFilter.processRequest(WroFilter.java:340)
    at ro.isdc.wro.http.WroFilter.doFilter(WroFilter.java:295)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: No webjar with uri: env.rhino.js available.
    at ro.isdc.wro.extensions.locator.WebjarUriLocator.locate(WebjarUriLocator.java:72)
    at ro.isdc.wro.extensions.script.RhinoScriptBuilder.addClientSideEnvironment(RhinoScriptBuilder.java:92)
    ... 42 more
Caused by: java.lang.IllegalArgumentException: env.rhino.js could not be found. Make sure you've added the corresponding WebJar and please check for typos.
    at org.webjars.WebJarAssetLocator.throwNotFoundException(WebJarAssetLocator.java:174)
    at org.webjars.WebJarAssetLocator.getFullPath(WebJarAssetLocator.java:213)
    at org.webjars.WebJarAssetLocator.getFullPath(WebJarAssetLocator.java:189)
    at ro.isdc.wro.extensions.locator.WebjarUriLocator.locate(WebjarUriLocator.java:69)
    ... 43 more


难道我做错了什么?只要文件org.webjars依赖项中已存在env.rhino.js的问题,该如何解决?任何不使用Maven插件的解决方案都是受欢迎的。

最佳答案

似乎对版本1.7.9的wro4j-extensions依赖项没有env.rhino.js。我将wro4j.version降级为1.7.0,并且工作正常。我假设wro4j-extensions被错误地删除了env.rhino.js,或者他们已经将其移至另一个地方。

10-08 19:06