Jawr Spring Annotations Based Sample Configuration

674 Views Asked by At

I wanted to implement Jawr for minification and obfuscation of CSS and JS resources. I am using a Spring MVC project where the configurations are done using Java code using annotations and XML is not used. Now able to find a documentation for the same. Can some one suggest me the configuration or a reference link.

1

There are 1 best solutions below

0
On

jawr dependencies to your pom:

    <dependency>
        <groupId>net.jawr</groupId>
        <artifactId>jawr-core</artifactId>
        <version>3.6</version>
    </dependency>
    <dependency>
        <groupId>net.jawr.extensions</groupId>
        <artifactId>jawr-spring-extension</artifactId>
        <version>3.6</version>
    </dependency>

Build a controller like this:

@Controller
public class JsController extends JawrSpringController
{
    public JsController ()
    {
        setType("js");
        setConfigLocation("/jawr.properties");
    }

    @RequestMapping("/js/**")
    public void javascript ( HttpServletRequest request, HttpServletResponse response ) throws Exception
    {
        handleRequest(request, response);
    }
}