When we test, we expect some exceptions to take place. Here we will see different ways to test methods with expected exceptions.
Objectives:
- How to write test cases that test expected exceptions?
When we test, we expect some exceptions to take place. Here we will see different ways to test methods with expected exceptions.
We have seen in Mybatis + Spring (XML | Annotation) Mapper how to write a simple mybatis-spring app and what is actually needed to get it up and running. Here I will extend that sample code to cover more stuff that you may face in a real “coding”. We will see how to make a single select that will fetch the one and the many of a “one-to-many” relationship, who to use mybatis config file with spring (if you need it), how to test mybatis-spring code using junit and things you need to watch out!
H2 embedded database has been used to make this example easy to run. But you still can use it with other databases e.g. “MySql, Oracle,….”
Objectives:
jQuery-File-Upload js library is “so far” the most elegant, smart, simple..etc js library I have used to upload files. Simply it is amazing. It supports async upload “Ajax”, multiple files upload, drag&drop, progress update and a lot more. Here we will see an example of uploading multiple files to Spring MVC app. Bootstrap has been used in this example to make the UI more attractive.
Objectives:
Here we will see what we need to do to connect to a relational database “MySql, Oracle, H2..etc” using myBatis with Spring framework & how to implement mappers using xml or annotation such as @Select, @Insert,….etc. For the sake of simplicity I have used H2 embedded database so you can run the sample code. However, you can use this sample code to run with MySql or any other relational database.
Source Code @ github
Note: If you have Maven you can run this sample code directly using ../spring-mybatis>mvn exec:java
Objectives:
If you create a java project using Maven you can run it using Maven.
Objective:
You can upload files to Spring MVC app in many different ways. For the server side, using MultipartHttpServletRequest is the easiest way to get uploaded files. For the client side we have different options, traditional synchronous method “using html form with submit” or asynchronous method by using Ajax.
Similar Post: Spring MVC + jQuery File Upload (multiple, drag&drop, progress…)
Objectives:
How to sort a map by keys or values?
One of the most viewed java question on Stackoverflow is How to sort a Map<Key, Value> on the values in Java? Here I will try to re-code one of the solutions in a clearer way!

Objective:
No code shall go to production without testing!

Objectives:
Using Spring MVC we can send the client data in JSON format, but what if the client send POST request with data in JSON format.
Objectives:
Using POJO as a centric data model for interacting with mongodb, can be achieved with Spring Data.
Objectives: