2

我正在尝试使 wro4j maven 插件正常工作,不幸的是,我遇到了一个我不太明白其原因的错误:

[ERROR] Failed to execute goal ro.isdc.wro4j:wro4j-maven-plugin:1.5.0:run (proprocess-   resources) on project someapp-webapp: Exception occured while processing: startup failed:
[ERROR] Script1.groovy: 1: unexpected token: < @ line 1, column 1.
[ERROR] <groups xmlns="http://www.isdc.ro/wro"

这是我的配置:

pom.xml:

<plugin>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>

    <executions>
        <execution>
            <id>proprocess-resources</id>
            <phase>compile</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <targetGroups>all</targetGroups>
        <wroFile>src/build/wro.xml</wroFile>
        <destinationFolder>${project.build.directory}/dist</destinationFolder>
        <contextFolder>${basedir}/src/main/webapp/</contextFolder>
        <extraConfigFile>src/build/wro.properties</extraConfigFile>
    </configuration>

</plugin>

这是我的 wro.xml 文件:

<groups xmlns="http://www.isdc.ro/wro"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.isdc.ro/wro wro.xsd">

  <group name="all">
    <js>/src/main/webapp/js</js>
    <css>/src/main/webapp/css</css>
  </group>

</groups>

我还有一个 wro.properties 文件:

debug=true
gzipResources=false
ignoreMissingResources=true
jmxEnabled=true
managerFactoryClassName=ro.isdc.wro.examples.manager.CustomWroManager
preProcessors=sassCss

我没有在 wro4j 文档中看到我可能错过的任何内容,如有任何建议,我将不胜感激!

4

2 回答 2

3

默认情况下,wro4j 使用SmartWroModelFactory,它尝试使用所有可用的 DSL 依次构建模型:xml、groovy、json。您的失败表明无法创建 xml 模型,因此它尝试将其创建为 groovy DSL。由于提供的 xml 模型似乎是有效的,因此失败的唯一原因是 xml 位置不是有效的。

可能您可以尝试替换:

<wroFile>src/build/wro.xml</wroFile><wroFile>/src/build/wro.xml</wroFile>

于 2013-01-12T14:57:04.323 回答
1

我发现我必须删除 XML 文件并在 wro4j 1.6.2 上创建一个 wro.groovy 文件。

groups {
  group1 {
    js("/app/**.js")
    css("/resources/css/*.css")
  }
  all {
    group1()
  }
}
于 2013-02-25T23:11:39.687 回答