In this Spring Data JPA One To One article, we will learn how to achieve One To One Mapping using Spring Data JPA. In this approach, we will have two tables with different primary keys. The primary key of EMPLOYEE table (EMP_ID) will act as a foreign key for the EMPLOYEE_ADDRESS table and EMPLOYEE_ADDRESS table will have its own primary key (ADDR_ID). [Read more…]
In this Spring MVC CRUD Example, we will be building a simple web-based Spring MVC Application (Employee management) which has the ability to perform CRUD Operations using Spring JdbcTemplate. Our Employee management application will have abilities to create a new employee, update the existing employee, get a particular employee/ all employee and finally delete the existing employee. [Read more…]
In this Spring CRUD Example, we will build a Simple Spring Application and perform CRUD operations using Spring JdbcTemplate. We will create a simple Employee management application which has abilities to create a new employee, update the existing employee, get a particular employee/ all employee and finally delete the existing employee. [Read more…]
By default, the embedded tomcat server of Spring Boot application will be starting at port 8080. In this article, we will learn how to change embedded Tomcat default port using one of the following approaches
- Using application.properties or application.yml
- Implementing EmbeddedServletContainerCustomizer interface
- Using SpringApplication class
- Change port directly through command line
Whenever you need, to perform a specific task once after all the Spring Beans are created and the Application Context has been created then you can implement ApplicationRunner or CommandLineRunner interface. Both the interfaces works the same way and has a single run() method. A similar implementation is already there in Spring and many people would have known it JobLauncherCommandLineRunner which is used for running jobs in Spring Batch. [Read more…]
Previously we have learnt how to build a Spring Boot Hello World application using Maven and through Eclipse. In this Spring Boot example we will be building the same hello world application with a slight difference instead of building a executable JAR we will be be building a WAR file. We will be extending SpringBootServletInitializer in order to create deployable WAR file. [Read more…]
In the previous Spring Security Hello World Example, we have built a simple Spring MVC Hello World application and took the advantage of Spring Security by using the default login form provided. In this tutorial we will go a bit further and build our own login for our Spring Security Custom Login Form application.
In this Spring RESTful Web Services example, we will learn how to create a RESTful Web Services directly through Spring Framework rather than creating it through REST implementation such as Jersey. In this article, we will create a REST service which returns XML representation of the Object. [Read more…]
When you happen to work with a Spring MVC Framework based Web application. Then java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener is a common problem which will be occurring during deployment. Spring MVC throws this exception when it is not able to find the “org.springframework.web.context.ContextLoaderListener” class which loads up the all the Spring MVC configuration files and other configuration files which is declared in the web.xml.
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/SpringMVC-servlet.xml, /WEB-INF/SpringSecurity.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
This exception will mostly happen when you start the server [Read more…]
It’s never a good practice to hard code and combine any environment related details such a username, password or file path etc. along with spring bean configuration. Usually in Java we will be having those details written in a separate property file and it will be read during the execution, the same can be followed in the spring as well using PropertyPlaceholderConfigurer.
Spring comes with a bean factory post processor called PropertyPlaceholderConfigurer which allows you to externalize those details into a properties file. In this Spring PropertyPlaceholderConfigurer Example we will learn how to use the PropertyPlaceholderConfigurer. [Read more…]