Accessing H2 in memory database

Accessing H2 in memory database integrated in spring application

Add below 2 beans in spring config. H2 console will be accessible on http://localhost:8082/

<bean id=“h2Server” class=“” factory-method=“createTcpServer” init-method=“start” destroy-method=“stop” depends-on=“h2WebServer”>
<constructor-arg value=“-tcp,-tcpAllowOthers,-tcpPort,9092”/>
<bean id=“h2WebServer” class=“” factory-method=“createWebServer” init-method=“start” destroy-method=“stop”>
<constructor-arg value=“-web,-webAllowOthers,-webPort,8082”/>

Adding internationalization support to spring mvc with thymeleaf

For basic Thymeleaf configuration check Spring MVC with Thymeleaf

Thymeleaf uses Standerd messange resolver unless specified which on to use. We can also use Spring internationalization support which will be supported by default by Thymeleaf.


  1. Add messages_en file to src/main/resources/
  2. Add spring beans those will support internationalization.
  3. LocaleChangeInterceptor is handler mapping that need to supports the multiple languages. The “paramName” is the parameter value that’s used to set the locale.
  4. Use ?lang=fr to change language to French from default English.

Source: Source Code

Spring MVC with thymeleaf

Spring MVC application with thymeleaf

Objective: Substitue view-layer web technologies such as JSP.

Pre-req: Spring STS as development environment

Why thymeleaf?: 

  • Natural templating for easy prototyping: display your templates statically in a browser (without running your app server).
  • Complete integration with Spring MVC (SpringStandard): form binding, property editors, internationalization, etc.
  • Full (and extensible) internationalization support: easy inclusion of externalized messages into templates.
  • URL rewriting capabilities for adding context and session information to URLs.
  • Spring Security support.
  • Out-of-the-box: templates can be read as classloader or ServletContext resources, as well as files (from the filesystem) and by calling URLs.


  1. Create spring mvc project
    • Go to File > New > Spring MVC Project
    • Select project name (ess) and top level package (com.njoshi.ess)
  2. Right click on project name > run on server to make sure project configuration is working
  3. Add thymeleaf dependancy
    • Open pom.xml
    • Add following dependancy
    • <dependency>
  4.  SpringTemplateEngine
    • Configure thymeleaf template engine in ess/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  5. Changes in home.jsp
    • Change home.jsp to home.html


Source code: