Skip to main content

Posts

Showing posts from April, 2016

Integrating Bootstrap with Spring MVC in Maven

We can integrate Bootstrap with Spring MVC in different ways. We are going to use one approach to do it. Bootstrap can be added as webjars . For this, put the following dependencies into the pom.xml. <dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>3.3.6</version> </dependency> You need to add a dependency for jQuery as well as follows. <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>2.2.3</version> </dependency> Now you are ready to go. But before that, add the following line of code to your servlet.xml file  <mvc:resources mapping="/webjars/**" location="/webjars/" /> Now add the following lines to your view pages within the head tag. <link rel="stylesheet" href="webjars/bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="style

How to create a SpringMVC web application in Eclipse with MongoDB and maven?

Use my previous blog post here  to create a basic helloworld SpringMVC web application without integrating it to a specific database. That will be a starting point for you to create this project that I am going to explain here with MongoDB. To know how to setup MongoDB have a look at my blog post here . This is if you are using a windows environment. I will list down the files that you need to create. As an overview, you will create or make use of the following files in this project. Song.java - This is the POJO or the model class that holds all the fields that should go in your database along with the getters and setters for the fields. Here the class represents a document(a record) that goes in the database. SongDAO.java - This is a java interface that contains the method declarations of the methods that will be used to perform database manipulations(that is the CRUD operations basically). SongDAOImpl.java - This class implements the SongDAO interface and provides the

Initial Integration steps of MongoDB with a Spring MVC web project in Eclipse using Maven

To start developing applications with MongoDB, you need to install a driver for your chosen programming language. I select Java here . There you don't need to download the driver if you are using maven to build the project. Just include the following dependency to the parent pom. <Your Language> -> Releases -> Installation will give the dependency that should be added. <dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.14.2</version> </dependency> </dependencies> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-commons</artifactId> <version>1.12.1.RELEASE</version> </dependency> But remember if you are including the below dependency, you don't need to put the dependency for the mongo-java-driver above. That is because

How to setup MongoDB on Windows?

Download the current MongoDB windows installation .msi file from https://www.mongodb.org/downloads   matching your requirement. Run the file and carry out the installation process. It is easy. You will be guided through the installation process. PS: The 3.2 and 3.0 releases of MongoDB does not work in windows. But the older releases does. In my case, I installed MongoDB 2.6 Standard version. Now open the command prompt and go to the bin folder of the MongoDB installation. In my case, it is C:\Program Files\MongoDB 2.6 Standard\bin Run the mongod.exe file there by typing the command                                                                       mongod You will find an error saying \data\db does not exists as shown in the figure below, and the .exe stops. Then go to the directory where MongoDB is installed and create a folder structure named data/db. But you can create it where ever you like. In my case it is as above. Then run the following command in the co

Create a Spring MVC web app in Eclipse

I take  http://o7planning.org/web/fe/default/en/document/8108/spring-mvc-tutorial-for-beginners site as a reference for this blog post. First create a maven project. (Be in the Spring mode to do this)                                       File -> New -> Maven Project Select the "Use default Workspace location" option and click Next. Under the "Select an Archetype" window, in "Filter" text field, type the word "webapp". Then from the listed set, select maven-archetype-webapp and click Next. Here you can specify a Group ID and an Artifact ID for the project and click on Finish to finish creating the basic structure of the project. Now you are ready to go with the implementation stuff. If you want to change the JRE for the project, right click on the "JRE System Library" folder and select "Properties". Here, the "Execution Environment" and the "Alternate JRE" options could be changed to th