1. In the Pom.xml file, introduce the Wro4j-maven-plugin plugin
- <plugin>
- <groupId>ro.isdc.wro4j</groupId>
- <artifactId>wro4j-maven-plugin</artifactId>
- <version>${wro4j.version}</version>
- <executions>
- <execution>
- <id>optimize-web-resources</id>
- <phase>compile</phase>
- <goals>
- <goal>Run</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <ignoreMissingResources>false</ignoreMissingResources>
- <jsDestinationFolder>
- ${project.build.directory}/${project.build.finalname}/static/js
- </jsDestinationFolder>
- <cssDestinationFolder>
- ${project.build.directory}/${project.build.finalname}/static/css
- </cssDestinationFolder>
- <wroManagerFactory>
- Ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
- </wroManagerFactory>
- </configuration>
- </plugin>
2. Configure the merge, compression policy, new file/web-inf/wro.xml, for example, the configuration content is:
- <? XML version="1.0" encoding="UTF-8"?>
- <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="Basic">
- <css>/static/css/front.css</css>
- <js>/static/js/jquery.js</js>
- <js>/static/js/jquery.paging.min.js</js>
- <js>/static/js/front/global.js</js>
- <js>/static/js/front/search.js</js>
- </group>
- <group name="Custom">
- <css>/static/css/front.css</css>
- <css>/static/css/comment/comment.css</css>
- <css>/static/plugins/syntaxhighlighter/shcore.css</css>
- <js>/static/js/front/coding.js</js>
- </group>
- </groups>
3. Configure wro4j related properties and create a new web-inf/wro.properties, for example, the configuration content is:
Configuration attribute meaning See also: http://everycoding.com/coding/68.html
- cacheupdateperiod=0
- modelupdateperiod= 0
- debug=true
- disablecache=
- gzipresources= true
- ignoremissingresources=false
This plugin must be configured with Wro.properties. Otherwise, the following exception will be reported when the package command is executed: Clean packages:
Src\main\webapp\web-inf\wro.properties (the system cannot find the file specified.) ), [Help 1]
4. Execute MAVEN command: Clean package packaging
We will find that the policies configured according to the Wro.xml
${project.build.directory}/${project.build.finalname}/static/js
The ${PROJECT.BUILD.DIRECTORY}/${PROJECT.BUILD.FINALNAME}/STATIC/CSS directory generates a
Basic.css, Basic.js, Custom.css, custom.js, etc. merge compressed files.
Maven plugin wro4j-maven-plugin compression, merge JS, css detailed