Posts

Showing posts from 2018

JPA vs Spring JPA vs Spring Data JPA vs Hibernate

JPA is the Java Persistence API , which is Java 's standard API for object-relational mapping . JPA is only an specification - you need an implementation of it to be able to use it. Hibernate is one of the most well-known and most used implementations of JPA, but there are others, such as EclipseLink JPA . The Spring Framework is a large framework to help you write enterprise-grade software easier. It contains support for many Java technologies, including JPA. The Spring Framework consists of a collection of projects , and one of these projects is Spring Data . The goal of Spring Data is to make it easier to work with different kinds of databases, from traditional relational databases to NoSQL databases. Spring Data supports JPA via the Spring Data JPA subproject. To write a program that uses JPA, you need at least a JPA implementation, such as Hibernate. If you are using the Spring Framework for your application, you will most likely want to use Spring Data JP...

Building Jersey Restful Web Services in Spring Boot.

What you need? Following are needed: java 8 maven 3.2 spring boot 1.5.8.RELEASE Maven pom.xml We will add  spring-boot-starter-parent  as a parent of our maven-based project. The added benefit of this is version management for Spring dependencies. < parent > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-parent </ artifactId > < version > 1.5.0.RELEASE </ version > </ parent > Adding the Spring-Boot-Starter-Jersey Dependency This will add/configure the Jersey-related dependencies. < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-jersey </ artifactId > </ dependency > The Full pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apach...

About Spring @Component, @Repository, @Service and @Controller Annotations.

Spring @Component , @Service , @Repository and @Controller annotations are used for automatic bean detection using classpath scan in Spring framework. These four  annotations are same logically. Differences between @Component, @Repository, @Controller and @Service: @Component  This is a general-purpose stereotype annotation(auto scan) indicating that the class is a spring component. @Component annotation picks them up and registers their following classes as beans, just as if they were annotated with @Component . @Repository This is special type of @Component annotation.   This is to indicate that the class defines a data repository.  @Controller This is special type of @Component annotation. The @Controller annotation indicates that a particular class serves the role of a controller. The @Controller annotation acts as a stereotype for the annotated class, indicating its role.  What’s special about @Controller? We cannot...

Change Liferay Default User Portrait

Step 1: Add the below given properties in portal-ext.properties file. portal-ext.properties file location : %LIFERAY_HOME%\tomcat-7.0.62\webapps\ROOT\WEB-INF\classes If there no file exists with this name, please create this. And then add below lines. image.default.user.female.portrait=com/images/user_female_portrait.png image.default.user.male.portrait=com/images/user_male_portrait.png Step 2: Add the default custom image under below given path %LIFERAY_HOME%\tomcat-7.0.62\webapps\ROOT\WEB-INF\classes\com\images\ Step 3: Restart the server Enjoy !!!!

Deploy Spring Boot application on Tomcat

Deploy Spring Boot application on Tomcat Step #1 Add the following dependency to pom.xml in order to tell Spring Boot not to use its embedded Tomcat. < dependency >      < groupId > org . springframework . boot < / groupId >      < artifactId > spring - boot - starter - tomcat < / artifactId >      < scope > provided < / scope > < / dependency > Step #2 Change the packaging property to war in pom.xml. < properties >        < packaging > war < / packaging > < / properties > Step #3 Replace your initializer class with the following: package com.oms; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServ...