1

我正在使用 wro4j-maven-plugin(版本 1.8.0)来构建我的网络资源:

          <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- Serves *only* to filter the wro.xml so it can get an absolute 
                            path for the project -->
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/wro</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/wro</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>ro.isdc.wro4j</groupId>
                <artifactId>wro4j-maven-plugin</artifactId>
                <version>1.8.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
                    <cssDestinationFolder>${project.build.directory}/generated-resources/static/css</cssDestinationFolder>
                    <jsDestinationFolder>${project.build.directory}/generated-resources/static/js</jsDestinationFolder>
                    <wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
                    <extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
                    <contextFolder>${basedir}/src/main/wro</contextFolder>
                    <ignoreMissingResources>false</ignoreMissingResources>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>jquery</artifactId>
                        <version>2.2.3</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>angularjs</artifactId>
                        <version>1.5.5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>bootstrap</artifactId>
                        <version>3.3.6</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>angular-ui-bootstrap</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>angular-ui-router</artifactId>
                        <version>0.2.18</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars.bower</groupId>
                        <artifactId>fontawesome</artifactId>
                        <version>4.5.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars.bower</groupId>
                        <artifactId>angular-resource</artifactId>
                        <version>1.5.5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>URI.js</artifactId>
                        <version>1.14.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

我的 wro.xml 看起来像这样:

<groups xmlns="http://www.isdc.ro/wro">
<group name="angular-bootstrap">
    <css>webjar:bootstrap/3.3.6/less/bootstrap.less</css>
    <css>webjar:fontawesome/4.5.0/less/font-awesome.less</css>
    <css>file:${project.basedir}/src/main/wro/main.less</css>
    <js>webjar:jquery/2.2.3/jquery.js</js>
    <js>webjar:bootstrap/3.3.6/js/bootstrap.js</js>     
    <js>webjar:angularjs/1.5.5/angular.js</js>
    <js>webjar:angular-resource/1.5.5/angular-resource.js</js>
    <js>webjar:angular-ui-router/0.2.18/angular-ui-router.js</js>
    <js>webjar:angular-ui-bootstrap/1.3.2/ui-bootstrap.js</js>
    <js>webjar:angular-ui-bootstrap/1.3.2/ui-bootstrap-tpls.js</js>
    <js>webjar:URI.js/1.14.1/URI.js</js>        
</group></groups>

这是我的 wro.properties 文件:

preProcessors=lessCssImport postProcessors=less4j,jsMin debug=true

当我运行 mvn clean install 时,出现以下错误:

[INFO] Executing the mojo:
[INFO] Wro4j Model path: D:\Entwicklungsumgebung\workspace.services\rs\src\main\wro\wro.xml
[INFO] targetGroups: null
[INFO] minimize: true
[INFO] ignoreMissingResources: false
[INFO] parallelProcessing: false
[INFO] buildDirectory: D:\Entwicklungsumgebung\workspace.services\rs\target
[INFO] destinationFolder: D:\Entwicklungsumgebung\workspace.services\rs\target
[INFO] jsDestinationFolder: D:\Entwicklungsumgebung\workspace.services\rs\target\generated-resources\static\js
[INFO] cssDestinationFolder: D:\Entwicklungsumgebung\workspace.services\rs\target\generated-resources\static\css
[INFO] The following groups will be processed: [angular-bootstrap]
[INFO] folder: D:\Entwicklungsumgebung\workspace.services\rs\target\generated-resources\static\css
[INFO] processing group: angular-bootstrap.css
[ERROR] Cannot ignore missing resource:  ro.isdc.wro.model.resource.Resource@77d680e6[CSS,file:${project.basedir}/src/main/wro/main.less,true]
[ERROR] Exception while merging resources: ${project.basedir}\src\main\wro\main.less (Das System kann den angegebenen Pfad nicht finden)
[ERROR] Exception occured while processing: ro.isdc.wro.WroRuntimeException: Exception while merging resources: ${project.basedir}\src\main\wro\main.less (Das System kann den angegebenen Pfad nicht finden), class: ro.isdc.wro.WroRuntimeException,caused by: java.io.**FileNotFoundException**
ro.isdc.wro.WroRuntimeException: Exception while merging resources: ${project.basedir}\src\main\wro\main.less (Das System kann den angegebenen Pfad nicht finden) 
4

2 回答 2

0

${project.basedir} 占位符不会被 maven 替换,因此 wro4j 会逐字搜索具有以下路径“${project.basedir}/src/main/wro/main.less”的资源,这显然是无效的。

用户 servlet 上下文相关资源、类路径资源、webjar 资源或绝对路径资源。

于 2016-08-29T10:11:36.723 回答
0

尝试mvn generate-resources在执行 Maven 目标窗口中执行命令。它有助于使用 Wro4J 从 Less 生成 CSS 文件,至少在 IntelliJ 中是这样。

于 2020-03-24T18:40:16.557 回答