IntelliJ IDEA: Webjars / Maven / Spring MVC - How do I import dependencies correctly and get them working?

So I am starting Java Web development and I just want some libraries to be imported into my IntelliJ project correctly using Maven. I stumbled upon using Webjars to import bootstrap and jquery, but I'm having big problems getting anything to work correctly. I wonder if anyone can help? Any suggestions are greatly appreciated.

My project currently has Maven and Spring MVC as supported frameworks. My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>JavaEEHelloWorld</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>LATEST</version>
            <exclusions>
                <exclusion>
                    <groupId>org.webjars</groupId>
                    <artifactId>jquery</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>

</project>

      

My spring-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

</beans>

      

My index.jsp:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Awesome site.</title>
    <link rel="stylesheet" href="/webjars/bootstrap/3.3.5/css/bootstrap.min.css"/>
    <script src="/webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="/webjars/jquery/3.0.0-alpha1/jquery.min.js"></script>
</head>
<body>
Hello World!
</body>
</html>

      

If I try to add the following line to my spring-config.xml I get this error: Can't solve

Other screenshots:

My project explorer, which for some reason never created subdirectories for bootstrap or jquery: Project explorer

Errors I see at runtime: Runtime errors

+3


source to share





All Articles