【问题标题】:yui compressor maven: A required class is missing: org.mozilla.javascript.ErrorReporteryui 压缩器 maven:缺少必需的类:org.mozilla.javascript.ErrorReporter
【发布时间】:2010-09-29 08:39:16
【问题描述】:

我无法在我的网络应用程序中使用 yui-compressor maven 插件。当我运行 maven 时出现以下错误

[信息] 插件管理器执行目标 'net.sf.alchim:yuicompressor-maven-plugin:0.7.1:compress' 出现内部错误:无法加载 mojo 'net.sf.alchim: yuicompressor-maven-plugin:0.7.1:compress' 在插件“net.sf.alchim:yuicompressor-maven-plugin”中。缺少必需的类:org.mozilla.javascript.ErrorReporter

后来我发现rhino js插件包含org.mozilla.javascript.ErrorReporter这个类。所以我在依赖标签中包含了这个插件,但我仍然得到同样的错误。

有没有人遇到过这样的错误。

--> 更新主要问题以添加 pom 插件详细信息

<plugin>
    <groupId>net.sf.alchim</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>0.7.1</version>  
    <executions>
      <execution>
     <phase>compile</phase>
        <goals>
         <goal>jslint</goal>
          <goal>compress</goal>
        </goals>
      </execution>
    </executions>        
    <configuration>
    <failOnWarning>true</failOnWarning>
      <nosuffix>true</nosuffix>
      <aggregations>
       <aggregation>
          <!-- remove files after aggregation (default: false) -->
          <removeIncluded>false</removeIncluded>
          <!-- insert new line after each concatenation (default: false) -->
          <insertNewLine>false</insertNewLine>
          <output>${project.basedir}/${webcontent.dir}/js/compressedAll.js</output>
          <!-- files to include, path relative to output's directory or absolute path-->
          <!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
          <includes>                
            <include>**/autocomplete.js</include>
            <include>**/calendar.js</include>
            <include>**/dialogs.js</include>
            <include>**/download.js</include>
            <include>**/folding.js</include>
            <include>**/jquery-1.4.2.min.js</include>
            <include>**/jquery.bgiframe.min.js</include>
            <include>**/jquery.loadmask.js</include>
            <include>**/jquery.printelement-1.1.js</include>
            <include>**/jquery.tablesorter.mod.js</include>
            <include>**/jquery.tablesorter.pager.js</include>
            <include>**/jquery.validate.js</include>  
            <include>**/jquery-ui-1.8.custom.min.js</include>
            <include>**/languageDropdown.js</include>
            <include>**/messages.js</include>
            <include>**/print.js</include>
            <include>**/tables.js</include>
            <include>**/tabs.js</include>
            <include>**/uwTooltip.js</include>
          </includes>
          <!-- files to exclude, path relative to output's directory-->

        </aggregation>
      </aggregations>
    </configuration>
    <dependencies>
         <dependency> 
 <groupId>rhino</groupId>  
  <artifactId>js</artifactId>       
  <scope>compile</scope>  
  <version>1.6R5</version> 
</dependency>  
<dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>2.0.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-project</artifactId>
        <version>2.0.7</version>
        <scope>provided</scope>
    </dependency><dependency>
        <groupId>net.sf.retrotranslator</groupId>
        <artifactId>retrotranslator-runtime</artifactId>
        <version>1.2.9</version>
        <scope>runtime</scope>
    </dependency>

    </dependencies>
  </plugin>                                                 

【问题讨论】:

  • 显示一个 pom、插件配置、允许复制的东西等可能会有所帮助。
  • 感谢您的回复。在 yui 压缩器的依赖项部分直接添加 rhino js 插件依赖项后,我能够删除此错误。但现在面临奇怪的问题。 yui 压缩器的压缩目标是将 js 文件聚合为一个,但实际上并不压缩。

标签: maven-2 yui-compressor


【解决方案1】:

你能试试最新版本(1.1)吗?

0.7.1 版本似乎甚至不是on the official repository。可能是依赖解析问题?

【讨论】:

    【解决方案2】:

    见话题Yui compressor StringIndexOutOfBoundsException on jboss

    在 web 应用程序上使用 yuicompressor 的唯一方法是手动将其与 rhino 依赖项合并。否则,要运行的应用程序将需要在类加载器加载序列中指定所需的 jar 序列(youcompressor 必须在 rhino 之前)。

    【讨论】:

    • 缺少正确的链接
    【解决方案3】:

    我也为缺少 ErrorReporter 类而苦苦挣扎。我通过构建一个 jar-with-dependencies 解决了这个问题,然后我转身在我的网络应用程序中使用它,

    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>attached</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    

    一旦我这样做了,一切正常。在我的 jar 中,我可以看到 org.mozilla.javascript.ErrorReporter.class 在那里,然后 Maven 将为我编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 2020-12-11
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 2013-10-13
      • 1970-01-01
      相关资源
      最近更新 更多