The @RestController annotation in Spring MVC is nothing but a combination of @Controller and @ResponseBody annotation. It was added into Spring 4.0 to make the development of RESTful Web Services in Spring framework easier. If you are familiar with the REST web services you know that the fundamental difference between a web application and a REST API is that the response from a web application is generally view (HTML + CSS + JavaScript) because they are intended for human viewers while REST API just returns data in form of JSON or XML because most of the REST clients are programs. This difference is also obvious in the @Controller and @RestController annotation.
Tuesday, March 21, 2023
Monday, March 20, 2023
Spring Boot + Hibernate Tutorial and Example for Java Developers
Hello guys, if you want to learn how to use Spring Boot and Hibernate together
in a Java application and look for examples and tutorials then you have come
to the right place. In the past, I have shared how to use Spring Boot with MyBatis and Spring Boot + Redis example and In this article on Spring Boot, we will discuss how to integrate
Spring Boot with Hibernate. We will build a simple Spring Boot application and
use Hibernate to store the data. So first, let's look at what is Hibernate in Java? Hibernate framework provides an abstraction layer which means
programmers need not worry about implementation. Hibernate will implement
different modules for developers internally like writing queries to perform
CRUD operations on the database and establishing connections to different
kinds of databases. This is a Java-based solution for object-relational
mapping.
Labels:
hibernate
,
spring
,
spring boot
Saturday, March 18, 2023
Difference between @ContextConfiguration and @SpringApplicationConfiguration in Spring Boot Testing?
Hello folks, what is the difference between @ContextConfiguration and @SpringApplicationConfiguration is one of the frequently asked Spring Boot Testing interview questions which is often used to check if the candidate knows about how to unit test Spring boot application. Even though both @ContextConfiguration and @SpringApplicationConfiguration annotations are used along with SpringJUnit4ClassRunner to specify how to load the Spring application context, there is a subtle difference between them. Although @ContextConfiguration does a great job in loading application context it doesn't take full advantage of Spring Boot features. Spring Boot applications are ultimately loaded by either SpringApplication ( in the case of the JAR) or SpringBootServletInitializer.
Labels:
spring
,
spring boot
,
spring interview questions
What is @SpringBootApplication Annotation in Java and Spring Boot? Example Tutorial
Hello guys, if you are wondering what is @SpringBootApplicaiton annotation and how to use it then you have come to the right place. Today, we'll learn about the @SpringBootApplication annotation, one of the most important annotations from the popular Spring Boot framework, which has changed the way Java developers use the Spring framework for writing Java applications. In this article, I'll explain to you the meaning of @SpringBootApplication and its use in a simple Spring Boot application. We use @SpringBootApplication annotation on our Application or Main class to enable a host of features e.g. Java-based Spring configuration, component scanning, and in particular for enabling Spring Boot's auto-configuration feature.
Labels:
spring
,
spring boot
Difference between BeanFactory and ApplicationContext in Spring Framework
The difference between BeanFactory and ApplicationContext in Spring framework is another frequently asked Spring interview question mostly asked Java programmers with 2 to 4 years experience in Java and Spring. Both BeanFactory and ApplicationContext provide a way to get a bean from the Spring IOC container by calling getBean("bean name"), but there is some difference in their working and features provided by them. One difference between the bean factory and application context is that the former only instantiates bean when you call getBean() method while ApplicationContext instantiates Singleton bean when the container is started, It doesn't wait for the getBean to be called.
Labels:
spring
,
spring interview questions
Thursday, March 16, 2023
What is a Spring Data Repository? JpaRepository, CrudRepository, and PagingAndSortingRepository Example
Hello Java developers, if you are wondering what is Spring Data Repository
interfaces like JpaRepository,
CrudRepository, and
PagingAndSortingRepository and how to
use them then you have come to the right place. Earlier, I have shared the
best Spring Data JPA courses
and in this article, I will give you an overview of different Spring Data
Repository interfaces and how to use them with step-by-step examples. The Java
Persistence API (JPA) is the standard way of persisting java objects into
relational databases.
Labels:
spring
,
spring data jpa
,
spring interview questions
Wednesday, March 15, 2023
Why use @Override annotation in Java? Coding Best Practice Example
@Override annotation was added in JDK 1.5 and it is used to instruct the compiler that method annotated with @Override is an overridden
method from super class
or interface.
Though it may look trivial @Override is particularly useful while overriding methods that accept Object as a parameter just like equals,
compareTo
or compare() method of Comparator interface. @Override is one of the three built-in annotations provided by
Java 1.5, the other two are @SuppressWarnings and @Deprecated.
Labels:
best practices
,
coding
,
core java
,
core java interview question
,
programming
10 Tips to Hire Programmers and Software Developers
Hello guys, For a change, this article is not for candidates who are preparing for interviews, but for those programmers who are responsible for taking interviews. At some point in your career as a programmer, you will have the responsibility to hire developers for your company. This is a big responsibility and your ability to select the right candidate will directly affect your company's future. This is more visible in small companies than the larger organization where a pool of interviewers exists. In a start-up, if you are a technical lead and responsible for hiring, it's a tough job. You have to hire the right candidate which fits in companies culture and competent enough to do the job they were hired for. To be frank, conducting interviews is as hard as giving interviews.
Labels:
best of javarevisited
,
programmers
,
programming
Friday, March 10, 2023
How to use MyBatis in Spring Boot application in Java? Example Tutorial
Hello guys, In this tutorial, we will discuss how to create a spring boot project with MyBatis. First, you need to have a better understanding of what is MyBatis and its use-cases. MyBatis is a SQL mapping framework with support for custom SQL, stored procedures, and advanced mapping. Although Spring Boot does not officially support MyBatis, the MyBatis community has created a Spring Boot startup for MyBatis.This is the most commonly used open-source framework for implementing SQL databases access in java applications.
Labels:
java
,
Mybatis
,
spring
,
spring boot
Thursday, March 9, 2023
Top 16 JMS (Java Messaging Service) Interview Questions and Answers
Java messaging Service or JMS interview questions is one of the important parts of any Core Java or J2EE interview as messaging is a key aspect of enterprise Java development. JMS is a popular open-source Messaging API and various vendors like Apache ActiveMQ, Websphere MQ, Sonic MQ provides an implementation of Java messaging API or JMS. Any Java messaging services or JMS interview can be divided into two parts where the first part focuses on fundamentals of JMS API and messaging concept like What is topic, What is Queue, publish-subscribe or point to point model, etc, While the second part is related to JMS experience with particular JMS provider.
Labels:
interview questions
,
Java Messaging Service
,
JMS
Top 20 Questions Candidate Should Ask in Programming Job Interviews?
From the first round to HR round, from telephonic to face-to-face, in almost all kind of programming interviews, there will be a time when Interviewer will give you a chance to ask questions. Many programmers are too concern about asking questions, and they politely decline ; Well it's your chance to learn about the Job you are going to do, and you shouldn't let this opportunity goes away. The interviewer, also judges you by your questions; a good, thoughtful, positive question can create the great impression on Interviewer's mind. It also shows that the interest of a candidate for a Job.
Labels:
interview questions
,
programming
Wednesday, March 8, 2023
Top 20 HTML Interview Questions with Answers for 1 to 3 Years Experienced
Hello guys, if you are preparing for web developer interview then you must prepare for HTML questions. HTML, CSS, and JavaScript is the backbone of web development and that's why every web develop is supposed to have good knowledge of these three technologies. In the past, I have shared JavaScript Interview Questions and CSS Interview questions and today, I will share 20 HTML Interview Questions with answers for web developer interview. If you have done web development work then most likely you already know answers of these question but if you feel lacking then you can always go through these best HTML online courses to learn and revise concept in depth.
Labels:
HTML and JavaScript
,
interview questions
How to enable disable Form elements in web page using jQuery? Example Tutorial
In last couple of tutorials you have learned how to get all selected checkbox and radio buttons, and in this tutorial, you will learn how to enable/disable form elements using jQuery. A form element e.g. a text field, radio buttons and checkbox, all represented using input tag can be enabled or disabled by adding an attribute called "disabled". It's similar to "checked" attribute we have seen for checkbox and radio buttons. If this attribute is not present then element is enable, but if this attribute is present then you can use disabled=true to disable the form element and disabled=false to enable the form elements as shown in our example. Like previous example of checking/unchecking checkbox, you can use prop() jQuery function to enable/disable form element if you are running on jQuery 1.6 or higher version and attr() function if you are running on jQuery 1.5 or lower version.
Labels:
HTML and JavaScript
,
JQuery
Monday, March 6, 2023
How to reload/refresh a page using JavaScript and jQuery? Example
Hello guys, if you are wondering how to reload or refresh a web page then don't worry JavaScript provides several ways to reload or refresh an HTML page but the standard way to do this job is by using window.location object. This object provides a reload() method which instructs the browser to reload the page. The browser can do it from its cache or from the server, which depends upon optional parameter i.e. reload(true) will reload the page from the server but reload(false) will only reload the page from the browser's cache, which may or may not represent the current version at the server.
Labels:
JavaScript
,
JQuery
Sunday, March 5, 2023
How to redirect a page or URL using JavaScript and JQuery - Example
Redirecting a web page means, taking the user to a new location. Many websites uses redirects for many different reasons, e.g. Some websites redirect users from the old domain to new domain, some redirect from one page to another e.g. a more relevant page. If you are a Java programmer and worked previously with Servlet and JSP, then you might be familiar with SendRedirect and Forward methods, which are used to redirect users in web applications. Actually, there are two kinds of redirect, Server side redirect, and client-side redirect. In Server side redirect, the server initiates redirection, while in a client-side redirect, the client code does the redirection. Redirecting a web page using JavaScript and JQuery is a client-side redirection.
Labels:
HTML and JavaScript
,
JQuery
Subscribe to:
Posts
(
Atom
)