Powered by Blogger.

Wednesday 27 December 2023

Multiples DATABASE Connection and Data shifting Using Spring Boots API

No comments :
Multiple DataBase Connection and Data shifting using Spring boot API configuration Example.
Step-by-step Write Java files.
1. application.properties File for Add multiple DataBase Connection. 
2. DBConfigDBNAME.JAVA Files for multiple DataBase Connection. 
3. Job Scheduler.java file for Auto shift programm. 
4. Entity Beans, Repository, Services Implementations for Binding and shifting Data.
  1. Create Spring Boot Java (Microservices)
      Create Spring Boot Java (Microservices).
  1. Project Name: DataShiftingConfigSpringBoots
  2. Group: DataShifting-a143mk
  3. Artifactid: DataShifting-a143mk
  4. Description: DataBase Connection and Data shifting using Spring boot API.
  5. Package: DataShiftinga143mk
Select the technologies and library(Maven Dependency ) to be.
  1. spring-boot-configuration-processor
  2. ojdbc8

while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


1. Configure application.properties


Create DataBase Configuration java Files :
DBConfigDATABASE1.java


DBConfigDATABASE2.java


DBConfigDATABASE3.java

Create Scheduler ClassCreate Scheduler for Auto run Program and import some Packages Scheduler.java as below:

Have you seen the previous post? You all know how to learn and create Entity Bean, Repository, Service Implementation in the project. If you don't know about it then go to the previous post and learn it.

Wednesday 17 May 2023

Learn I- Report configuration with Spring boot/Microservices using Java

1 comment :
iReport
iReport is a powerful graphical design tool for report designers and power users to define reports for execution using the JasperReports engine. Whether you are using the JasperReports library by itself as a critical component of your application or you are using it as a component of the JasperReports Server application, iReport can help you design reports to meet the most complex reporting demands. iReport is built on the NetBeans platform and is available as a standalone application or as a Netbeans plug-in.
Requirements For current Download JasperReports iReport Tools , Ckeck It is recommended that you run iReport with JDK v1.5,v1.6 or v1.7. Note that for Windows Vista users, it is recommended that you run JDK v1.7.
JasperReports Create very sophisticated layouts containing charts, images, subreports, crosstabs and much more. Access your data through JDBC, TableModels, JavaBeans, XML, Hibernate, CSV, and custom sources. Then publish your reports as PDF, RTF, XML, XLS, CSV, HTML, XHTML, text, DOCX, or OpenOffice. Through this post, we will tell you how to configure iReport in Mavan base java application(Microservices) project. follows step by step:

  1. Create Spring Boot Java (Microservices)
  2. Create/Design report.jrxml
Create Spring Boot Java (Microservices).
  1. Project Name: I-ReportConfigurationApp
  2. Group:I-Report-a143mk
  3. Artifactid:I-Report-a143mk
  4. Description:Learn I- Report configuration with Microservices Application
  5. Package:I-Report-a143mk




Select the technologies and library(Maven Dependency ) to be.
  1. Spring Web
  2. Spring JPA
  3. Jasperreports
  4. javax.persistence
  5. Tomcat
  6. javax.servlet
  7. mysql
  8. jstl

while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


For step by step development working watch the video and learn yourself. Download wampServer2.0i and install then run it.



1. Create Database: Database Name is hostel.
2. Create Table: Table Name is product.




Configure application.properties


Report:
In src/main/resources/reports/report.jrxml folder, create new folder named reports. In this folder, create new Jasper Report named report.jrxml as below:
 


Code:



Entities Class
Create new package, named IReporta143mk.entities. In this package, create entities class name is Product.java as below:



Create ProductRepository Interface
Create new package named IReporta143mk.repositories. In this package create the ProductRepository interface implements from CrudRepository interface of Spring Data JPA that provides CRUD Operations for an entity.


Create ProductService Interface
Create new package named IReporta143mk.services. In this package create the ProductService interface and ProductServiceImpl as below:
First one is ProductService.java


Second one is ProductServiceImpl.java



Create Controllers
Create new package named IReporta143mk.controllers. In this package, create new java class named ProductController.java


Create jsp page
Create new folder name is jsp. In thes folder /src/main/webapp/WEB-INF/jsp/index.jsp

Structure of Spring Boot Project:


Out Put:




Tuesday 3 January 2023

Single Sign-On (SSO) Using SMTP Authentication With Spring Boot Microservices

2 comments :
Single sign-on is an authentication scheme that allows a user to log in with a single ID to any of several related, independent, software systems or web applications. In this Video user will login through Outlook and Google Mail for which we will develop Spring Boot Microservices Project here and will also use some Spring Boot Jar files javax.mail.jar and SendMailA143mkSSO.jar
Process of Single sign-On (SSO) Authentication:




Download both the jar file and implement some methods / functions have been used, the names of the methods are as follows:

Create Class object SendMailA143mk getsess=new SendMailA143mk();
  1. LoginMailAuthHost_PortA143mk();
  2. OutLookMailAuthA143mk();
  3. GmailMailAuthA143mk();
There are some parameters in five methods, which we initialize by creating and object like this.

String toAuthmail="EmailMail@mailDomen.com";
String toAuthmailPassword="mailPassword"; 
String host="smtp.office365.com"; 
String port="587"; 

How to create a project to follow us. Project Name is: EmailAuthenticationA143mk




while creating the project pom.xml file and some maven dependency, main class is automatically created when web add any dependency like.

pom.xml


For step by step development working watch the video and learn yourself.


Some Helping Note: Some code and video are shown in this post, how we can use it in our application, the developer and jar file used in this is verified by mail id and password and after mail id is successful is returned, you can then write custom user roles and method entities in the block. and you can write error body in second part of it.

Wednesday 13 July 2022

Social Client Login with OAuth2 Spring Boot Application

2 comments :
First of all you have to take auth2 access to the social web site, we see it in the video, then we will create a services and test it and see some services we learned in the previous post, we will give their link below which includes Eureka (client-1, client-2)ApiGetway, services.



Add client and secret Id in ApiGetway application.properties  file:

spring.security.oauth2.client.registration.Oauth2_Security.client-id = Write your Client ID spring.security.oauth2.client.registration.Oauth2_Security.client-secret = Write your Secret ID

Add use Dependency in ApiGetway pom.xml  file:

Add New Package in ApiGetway-> com.javatechie.spring.zulu.api.cofig and create SecurityConfiguration.java file.


See the video step by step to run/learn past post video and current configuration post.




How to Develop Some Other Rest API How to Develop Eureka Server and Eureka Client Configuration How to Develop GateWayAPI How to get Google Token

Wednesday 15 June 2022

How to Develop Log4j for logging configuration and implementation in spring boot project/Application.

2 comments :
Introduction
Log4j is designed for both beginners and professionals. Our blogs post provides all the basic and advanced concepts of Log4j, such as Log4j for logging configuration and implementation etc. Log4j is a fast, reliable and flexible logging framework which is written in java. It is an open-source logging API for java. Simply the logging means some way to indicate the state of the system at runtime. Logs are used to capture and persists the important data and make it available for analysis at any point in time. Log4j2 is broken up in an API and an implementation (core), where the API provides the interface that applications should code to. Strictly speaking Log4j core is only needed at runtime and not at compile time. However, below we list Log4j as a compile time dependency to improve the startup time for custom plugins as it provides an annotation processor that generates a metadata file to cache plugin information as well as the necessary code to compile against to create custom plugins. . 
Using Log4j in your Apache Maven build To build with Apache Maven, add the dependencies listed below to your pom.xml file.


To keep your Log4j module versions in sync with each other, a pom.xml file is provided for your convenience. To use this with Maven, add the dependency listed below to your pom.xml file. When you specify the version identifier in this section, you don't have to specify the version in your section. pom.xml


Write a configuration of application.properties



As the file Path is given in the application.properties file, you have to create a folder named logs inside the project with the same name, you can also change its name. you will get to see all this in the video.

Go to The Live Example Video 

Thursday 2 June 2022

Run Multiple Microservices on single Port Using Zuul

1 comment :
Information
As you must have seen in these blogs links Multiple Microservices with Eureka Client Configuration that how we develop microservices and register those services on eureka server and we have seen how every service run on different port Number.
Introduction
Zuul is a JVM- based router and server-side load balance form Netflix.
Zuul's rule engine provides flexibility to write rules and filters to enhance routing in a spring cloud microservices architecture.
Routing it is an integral port of a microservice architecture.
How to Include Zuul Dependency
dependency: 
                groupid: org.springframework.cloud 
                 artifactid: spring-cloud-starter-netflix-zuul

Enbedded Zuul Reverse Proxy To enable it, annotate a spring boot man class with @EnableZuulProxy.
How to write Main Class Name is:A143mkGatewayApplication.java

Filter Class
Base abstract class for Zuulfilters. the base class defines abstract methods to define: filterType()- to classify a filter by type. standard type in Zuul are
  1. ErrorFilter
  2. PostFilter
  3. PreFilter
  4. RouteFilter

ErrorFilter.java

PostFilter.java

PreFilter.java

RouteFilter.java

application.properties
## client1-1 API URL 
zuul.routes.client-service-1.path=/cli-api/** 
zuul.routes.client-service-1.url=http://localhost:8081/ 
## client1-2 API URL 
zuul.routes.client-service-2.path=/cli2-api/** 
zuul.routes.client-service-2.url=http://localhost:8082/ 
ribbon.eureka.enabled=false 
server.port=8080

Create pom.xml

For step by step development working watch the video and learn yourself.





Saturday 29 January 2022

Spring boot for Microservices with Eureka Client Configuration

1 comment :
Eureka Server is an application that holds the information about all client-service applications. Every Micro service will register into the Eureka server and Eureka server knows all the client applications running on each port and IP address. Eureka Server is also known as Discovery Server.
 

How to Building a Eureka Server
Create Eureka Server: Project Name is ureka-server
Create ServletInitializer.java class and extends SpringBootServletInitializer
Check Main Class is Name of UrekaServerApplication to add Annotations

Create application.properties
server.port=8761 
eureka.client.register-with-eureka=false 
eureka.client.fetch-registry=false

Create pom.xml
Write Click to Project Node and Run as Spring Boot App Output check on Browser to write URL http://localhost:8761/



How to Building a client Service
We have to create Two client Service are name Demo and demo-u2 
Create Demo API:
Create Controller Class is Name of BaseController add add Annotations

Check Main Class is Name of DemoApplication and add Annotations

Create application.properties
server.port=8081 
spring.application.name=client-service-1 
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:8761/eureka

Create pom.xml

Write Click to Project Node Demo and Run as Spring Boot App Reload the browser and check Instances currently registered with Eureka.






Similarly you can create dem-u2 client API, if there is nay problem then you can watch the video Link:
.

Wednesday 10 February 2021

Spring Boot for Microservices

1 comment :
Spring Boot:
Spring Boot is an opinionated Java framework for building microservices based on the Spring dependency injection framework. Spring Boot allows developers to create microservices through reduced boilerplate, configuration, and developer friction. This is a similar approach to the two other frameworks we’ll look at. 
Spring Boot does this by: 
  • Favoring automatic, conventional configuration by default.
  • Curating sets of popular starter dependencies for easier consumption.
  • Simplifying application packaging.  
  • Baking in application insight (e.g., metrics and environment info)

Dependencies:
Spring was used in large enterprise applications that typically leveraged lots of different technology to do the heavy lifting: JDBC databases, message queues, file systems, application-level caching, etc. A developer would have to stop what she’s doing, switch cognitive contexts, figure out what dependencies belonged to which piece of functionality (“Oh, I need the JPA dependencies!”) and spend lots of time sorting out versioning mismatches or issues that would arise when trying to use these various pieces together. Spring Boot offers a large collection of curated sets of libraries for adding these pieces of functionality.  
These starter modules allow you to add things like: 
  • JPA persistence.
  • NoSQL databases like MongoDB, OracleDB, and Couchbase.
  • Redis caching.  
  • Tomcat/Jetty/Undertow servlet engine
  • JTA transactions.  

Adding a submodule to your application brings in the curated set of transitive dependencies and versions that are known to work together saving developers from having to sort out dependencies themselves.
The spring-tool-suite-4-4.2.0 can be installed a few different ways, including through package managers and by downloading Tools it straight from the website. Check for instructions on installing the STS most appropriate for your development environment. Once you’ve installed the STS tools, you should be able to check the version of Spring you have:
$ spring --version sts-4.2.0.RELEASE

Hello Example: Now that we have a Spring Boot application that can run, let’s add some simple functionality. We want to expose an HTTP/REST endpoint at /api/indexGet that will return “Hello Spring Boot from X” where X is the IP address where the service is running. To do this, navigate to src/main/java/com/a134mk/springboots. This location should have been created for you if you followed the preceding steps; remember, the groupId we passed to the spring init program did not apply groupId to the Java package hierarchy, and we’ve left it as it is which should be “com.a134mk”. Then create a new Java class called HolaRestController, as shown in code block. We’ll add a method named Hello() that returns a string along with the IP address of where the service is running. we’re going to make use of the following annotations in Example :
Let’s see what it takes to enable the actuator. Open up the pom.xml file for your Hello Spring Boot for microservice and add the following Maven dependency within
 the "<dependencies>...</dependencies>"  section:



@RestController 
 Tell Spring this is an HTTP controller capable of exposing HTTP endpoints (GET, PUT, POST, etc.). 
@RequestMapping 
 Map specific parts of the HTTP URI path to classes, methods, and parameters in the Java code. Note, import statements are omitted.


Go to Run->
OUTPUT:

Check Video for Similar Spring Boot Configuration:

Go Link...