Spring DI – Collections Setter

Spring DI – Collections Setter ”; Previous Next You have seen how to configure primitive data type using value attribute and object references using ref attribute of the <property> tag in your Bean configuration file. Both the cases deal with passing singular value to a bean. Now what if you want to pass plural values like Java Collection types such as List, Set, Map, and Properties. To handle the situation, Spring offers following types of collection configuration elements which are as follows − Sr.No Element & Description 1 <list> This helps in wiring ie injecting a list of values, allowing duplicates. 2 <set> This helps in wiring a set of values but without any duplicates. 3 <props> This can be used to inject a collection of name-value pairs where the name and value are both Strings. You can use either <list> or <set> to wire any implementation of java.util.Collection or an array. In this example, we”re showcasing passing direct values of the collection elements. Example The following example shows a class JavaCollection that is using collections as dependency injected using setters. Let”s update the project created in Spring DI – Create Project chapter. We”re adding following files − JavaCollection.java − A class containing a collections as dependency. MainApp.java − Main application to run and test. Here is the content of JavaCollection.java file − package com.tutorialspoint; import java.util.*; public class JavaCollection { List<String> addressList; Set<String> addressSet; Properties addressProp; // a setter method to set List public void setAddressList(List<String> addressList) { this.addressList = addressList; } // prints and returns all the elements of the list. public List<String> getAddressList() { System.out.println(“List Elements :” + addressList); return addressList; } // a setter method to set Set public void setAddressSet(Set<String> addressSet) { this.addressSet = addressSet; } // prints and returns all the elements of the Set. public Set<String> getAddressSet() { System.out.println(“Set Elements :” + addressSet); return addressSet; } // a setter method to set Property public void setAddressProp(Properties addressProp) { this.addressProp = addressProp; } // prints and returns all the elements of the Property. public Properties getAddressProp() { System.out.println(“Property Elements :” + addressProp); return addressProp; } } Following is the content of the MainApp.java file − package com.tutorialspoint; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“applicationcontext.xml”); JavaCollection jc=(JavaCollection)context.getBean(“javaCollection”); jc.getAddressList(); jc.getAddressSet(); jc.getAddressProp(); } } Following is the configuration file applicationcontext.xml which has configuration for all the type of collections − <?xml version = “1.0” encoding = “UTF-8”?> <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = “http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> <!– Definition for javaCollection –> <bean id = “javaCollection” class = “com.tutorialspoint.JavaCollection”> <!– results in a setAddressList(java.util.List) call –> <property name = “addressList”> <list> <value>INDIA</value> <value>JAPAN</value> <value>USA</value> <value>UK</value> </list> </property> <!– results in a setAddressSet(java.util.Set) call –> <property name = “addressSet”> <set> <value>INDIA</value> <value>JAPAN</value> <value>USA</value> <value>UK</value> </set> </property> <!– results in a setAddressProp(java.util.Properties) call –> <property name = “addressProp”> <props> <prop key = “one”>INDIA</prop> <prop key = “two”>JAPAN</prop> <prop key = “three”>USA</prop> <prop key = “four”>UK</prop> </props> </property> </bean> </beans> Output Once you are done creating the source and bean configuration files, let us run the application. If everything is fine with your application, it will print the following message − List Elements :[INDIA, JAPAN, USA, UK] Set Elements :[INDIA, JAPAN, USA, UK] Property Elements :{four=UK, one=INDIA, two=JAPAN, three=USA} Print Page Previous Next Advertisements ”;

Spring DI – Constructor Based

Spring DI – Constructor-Based ”; Previous Next Constructor-Based DI is accomplished when the container invokes a class constructor with a number of arguments, each representing a dependency on the other class. Example The following example shows a class TextEditor that can only be dependency-injected with constructor injection. Let”s update the project created in Spring DI – Create Project chapter. We”re adding following files − TextEditor.java − A class containing a SpellChecker as dependency. SpellChecker.java − A dependency class. MainApp.java − Main application to run and test. Here is the content of TextEditor.java file − package com.tutorialspoint; public class TextEditor { private SpellChecker spellChecker; public TextEditor(SpellChecker spellChecker) { System.out.println(“Inside TextEditor constructor.” ); this.spellChecker = spellChecker; } public void spellCheck() { spellChecker.checkSpelling(); } } Following is the content of another dependent class file SpellChecker.java package com.tutorialspoint; public class SpellChecker { public SpellChecker(){ System.out.println(“Inside SpellChecker constructor.” ); } public void checkSpelling() { System.out.println(“Inside checkSpelling.” ); } } Following is the content of the MainApp.java file. package com.tutorialspoint; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“applicationcontext.xml”); TextEditor te = (TextEditor) context.getBean(“textEditor”); te.spellCheck(); } } Following is the configuration file applicationcontext.xml which has configuration for the constructor-based injection − <?xml version = “1.0” encoding = “UTF-8”?> <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = “http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> <!– Definition for textEditor bean –> <bean id = “textEditor” class = “com.tutorialspoint.TextEditor”> <constructor-arg ref = “spellChecker”/> </bean> <!– Definition for spellChecker bean –> <bean id = “spellChecker” class = “com.tutorialspoint.SpellChecker”></bean> </beans> Output Once you are done creating the source and bean configuration files, let us run the application. If everything is fine with your application, it will print the following message − Inside SpellChecker constructor. Inside TextEditor constructor. Inside checkSpelling. Print Page Previous Next Advertisements ”;

Spring DI – Map Ref Constructor

Spring DI – Map Ref Constructor ”; Previous Next You have seen how to configure primitive data type using value attribute and object references using ref attribute of the <property> tag in your Bean configuration file. Both the cases deal with passing singular value to a bean. Now what if you want to pass Map. In this example, we”re showcasing passing direct values of the Map using constructor injection. Example The following example shows a class JavaCollection that is using collections as dependency injected using constructor arguments. Let”s update the project created in Spring DI – Create Project chapter. We”re adding following files − Address.java − A class to be used as dependency. JavaCollection.java − A class containing a collections of dependencies. MainApp.java − Main application to run and test. Here is the content of Address.java file − package com.tutorialspoint; public class Address { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return name; } } Here is the content of JavaCollection.java file − package com.tutorialspoint; import java.util.*; public class JavaCollection { Map<String, Address> addressMap; public JavaCollection() {} public JavaCollection(Map<String, Address> addressMap) { this.addressMap = addressMap; } // a setter method to set Map public void setAddressMap(Map<String, Address> addressMap) { this.addressMap = addressMap; } // prints and returns all the elements of the Map. public Map<String, Address> getAddressMap() { System.out.println(“Map Elements :” + addressMap); return addressMap; } } Following is the content of the MainApp.java file − package com.tutorialspoint; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“applicationcontext.xml”); JavaCollection jc=(JavaCollection)context.getBean(“javaCollection”); jc.getAddressMap(); } } Following is the configuration file applicationcontext.xml which has configuration for all the type of collections − <?xml version = “1.0” encoding = “UTF-8”?> <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = “http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> <bean id = “address1” class = “com.tutorialspoint.Address”> <property name=”name” value=”INDIA”></property> </bean> <bean id = “address2” class = “com.tutorialspoint.Address”> <property name=”name” value=”JAPAN”></property> </bean> <bean id = “address3” class = “com.tutorialspoint.Address”> <property name=”name” value=”USA”></property> </bean> <bean id = “address4” class = “com.tutorialspoint.Address”> <property name=”name” value=”UK”></property> </bean> <bean id = “javaCollection” class = “com.tutorialspoint.JavaCollection”> <constructor-arg name = “addressMap”> <map> <entry key = “1” value-ref = “address1″/> <entry key = “2” value-ref = “address2″/> <entry key = “3” value-ref = “address3″/> <entry key = “4” value-ref = “address4″/> </map> </constructor-arg> </bean> </beans> Once you are done creating the source and bean configuration files, let us run the application. If everything is fine with your application, it will print the following message − Map Elements :{1=INDIA, 2=JAPAN, 3=USA, 4=UK} Print Page Previous Next Advertisements ”;

Spring Boot CLI – Packaging Application

Spring Boot CLI – Packaging Application ”; Previous Next Spring boot CLI provides jar command in order to package a application as jar file. Let”s test the sample project created in Starter Thymeleaf Project Chapter to demonstrate the packaging capabilities of Spring CLI. Follow the below mentioned step to package the sample project. Package the application Type the following command E:/Test/TestApplication/> spring jar TestApplication.jar *.groovy Output Now you can see two new files created in TestApplication folder. TestApplication.jar − An executable jar file. TestApplication.jar.original − Original jar file. Include/Exclude By default following directories are included along with their contents. public resources static templates META-INF By default following directories are excluded along with their contents. repository build target *.jar files *.groovy files Using –include, we can include directories excluded otherwise. Using –exclude, we can exclude directories included otherwise. Running the Executable Jar Type the following command E:/Test/TestApplication/> java -jar TestApplication.jar You can see the following output on console. . ____ _ __ _ _ /\ / ___”_ __ _ _(_)_ __ __ _ ( ( )___ | ”_ | ”_| | ”_ / _` | \/ ___)| |_)| | | | | || (_| | ) ) ) ) ” |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.6.3) 2022-02-03 11:47:42.298 INFO 8908 — [ main] .b.c.a.PackagedSpringApplicationLauncher : Starting PackagedSpringApplicationLauncher using Java 11.0.11 on DESKTOP-86KD9FC with PID 8908 (E:TestTestApplicationTestApplication.jar started by intel in E:TestTestApplication) 2022-02-03 11:47:42.310 INFO 8908 — [ main] .b.c.a.PackagedSpringApplicationLauncher : No active profile set, falling back to default profiles: default 2022-02-03 11:47:44.839 INFO 8908 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-02-03 11:47:44.863 INFO 8908 — [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-02-03 11:47:44.864 INFO 8908 — [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56] 2022-02-03 11:47:44.958 INFO 8908 — [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-02-03 11:47:44.959 INFO 8908 — [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1943 ms 2022-02-03 11:47:45.592 INFO 8908 — [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html] 2022-02-03 11:47:46.492 INFO 8908 — [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ”” 2022-02-03 11:47:46.514 INFO 8908 — [ main] .b.c.a.PackagedSpringApplicationLauncher : Started PackagedSpringApplicationLauncher in 5.295 seconds (JVM running for 6.089) Browse the application in Browser Our spring based rest application is now ready. Open url as “http://localhost:8080/” and you will see the following output. Go to Message Click on Message link and you will see the following output. Message: Welcome to TutorialsPoint.Com! Print Page Previous Next Advertisements ”;

Spring DI – Collections Constructor

Spring DI – Injecting Collections Constructor ”; Previous Next You have seen how to configure primitive data type using value attribute and object references using ref attribute of the <property> tag in your Bean configuration file. Both the cases deal with passing singular value to a bean. Now what if you want to pass plural values like Java Collection types such as List, Set, and Properties. To handle the situation, Spring offers following types of collection configuration elements which are as follows − Sr.No Element & Description 1 <list> This helps in wiring ie injecting a list of values, allowing duplicates. 2 <set> This helps in wiring a set of values but without any duplicates. 3 <props> This can be used to inject a collection of name-value pairs where the name and value are both Strings. You can use either <list> or <set> to wire any implementation of java.util.Collection or an array. In this example, we”re showcasing passing direct values of the collection elements. Example The following example shows a class JavaCollection that is using collections as dependency injected using constructor arguments. Let”s update the project created in Spring DI – Create Project chapter. We”re adding following files − JavaCollection.java − A class containing a collections as dependency. MainApp.java − Main application to run and test. Here is the content of JavaCollection.java file − package com.tutorialspoint; import java.util.*; public class JavaCollection { List<String> addressList; Set<String> addressSet; Properties addressProp; public JavaCollection() {} public JavaCollection(List<String> addressList, Set<String> addressSet, Properties addressProp) { this.addressList = addressList; this.addressSet = addressSet; this.addressProp = addressProp; } // a setter method to set List public void setAddressList(List<String> addressList) { this.addressList = addressList; } // prints and returns all the elements of the list. public List<String> getAddressList() { System.out.println(“List Elements :” + addressList); return addressList; } // a setter method to set Set public void setAddressSet(Set<String> addressSet) { this.addressSet = addressSet; } // prints and returns all the elements of the Set. public Set<String> getAddressSet() { System.out.println(“Set Elements :” + addressSet); return addressSet; } // a setter method to set Property public void setAddressProp(Properties addressProp) { this.addressProp = addressProp; } // prints and returns all the elements of the Property. public Properties getAddressProp() { System.out.println(“Property Elements :” + addressProp); return addressProp; } } Following is the content of the MainApp.java file − package com.tutorialspoint; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“applicationcontext.xml”); JavaCollection jc=(JavaCollection)context.getBean(“javaCollection”); jc.getAddressList(); jc.getAddressSet(); jc.getAddressProp(); } } Following is the configuration file applicationcontext.xml which has configuration for all the type of collections − <?xml version = “1.0” encoding = “UTF-8”?> <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = “http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> <bean id = “javaCollection” class = “com.tutorialspoint.JavaCollection”> <constructor-arg name = “addressList”> <list> <value>INDIA</value> <value>JAPAN</value> <value>USA</value> <value>UK</value> </list> </constructor-arg> <constructor-arg name = “addressSet”> <set> <value>INDIA</value> <value>JAPAN</value> <value>USA</value> <value>UK</value> </set> </constructor-arg> <constructor-arg name = “addressProp”> <props> <prop key = “one”>INDIA</prop> <prop key = “two”>JAPAN</prop> <prop key = “three”>USA</prop> <prop key = “four”>UK</prop> </props> </constructor-arg> </bean> </beans> Once you are done creating the source and bean configuration files, let us run the application. If everything is fine with your application, it will print the following message − List Elements :[INDIA, JAPAN, USA, UK] Set Elements :[INDIA, JAPAN, USA, UK] Property Elements :{four=UK, one=INDIA, two=JAPAN, three=USA} Print Page Previous Next Advertisements ”;

Spring DI – Static Factory

Spring DI – Static Factory ”; Previous Next Spring provides an option to inject dependency using factory-method attribute. Example The following example shows a class TextEditor that can only be dependency-injected using pure setter-based injection. Let”s update the project created in Spring DI – Create Project chapter. We”re adding following files − TextEditor.java − A class containing a SpellChecker as dependency. SpellChecker.java − A dependency class. MainApp.java − Main application to run and test. Here is the content of TextEditor.java file − package com.tutorialspoint; public class TextEditor { private SpellChecker spellChecker; private String name; public void setSpellChecker( SpellChecker spellChecker ){ this.spellChecker = spellChecker; } public SpellChecker getSpellChecker() { return spellChecker; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void spellCheck() { spellChecker.checkSpelling(); } } Following is the content of another dependent class file SpellChecker.java − This class constructor is private. So its object can not be created directly using new operator by other object. It has a static factory method to get an instance. package com.tutorialspoint; public class SpellChecker { private SpellChecker(){ System.out.println(“Inside SpellChecker constructor.” ); } public static SpellChecker getInstance() { System.out.println(“Inside SpellChecker getInstance.” ); return new SpellChecker(); } public void checkSpelling(){ System.out.println(“Inside checkSpelling.” ); } } Following is the content of the MainApp.java file − package com.tutorialspoint; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MainApp { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(“applicationcontext.xml”); TextEditor te = (TextEditor) context.getBean(“textEditor”); te.spellCheck(); } } Following is the configuration file applicationcontext.xml which has configuration for autowiring byName − <?xml version = “1.0” encoding = “UTF-8”?> <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = “http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> <!– Definition for textEditor bean –> <bean id = “textEditor” class = “com.tutorialspoint.TextEditor” autowire = “byName”> <property name = “name” value = “Generic Text Editor” /> </bean> <!– Definition for spellChecker bean –> <bean id = “spellChecker” class = “com.tutorialspoint.SpellChecker” factory-method=”getInstance”></bean> </beans> Once you are done creating the source and bean configuration files, let us run the application. If everything is fine with your application, it will print the following message − Inside SpellChecker getInstance. Inside SpellChecker constructor. Inside checkSpelling. Print Page Previous Next Advertisements ”;

Spring ORM – Run & Test EclipseLink

Spring ORM – Test EclipseLink ”; Previous Next Now in eclipse, right click on the MainApp.java, select Run As context menu, and select Java Application. Check the console logs in the eclipse. You can see the below logs − … Sep 28, 2021 8:56:13 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean createNativeEntityManagerFactory INFO: Building JPA EntityManagerFactory for persistence unit ”EclipseLink_JPA” [EL Config]: metadata: 2021-09-28 08:56:13.763–ServerSession(712627377)–Thread(Thread[main,5,main])–The access type for the persistent class [class com.tutorialspoint.jpa.entity.Employee] is set to [FIELD]. [EL Config]: metadata: 2021-09-28 08:56:13.787–ServerSession(712627377)–Thread(Thread[main,5,main])–The alias name for the entity class [class com.tutorialspoint.jpa.entity.Employee] is being defaulted to: Employee. [EL Config]: metadata: 2021-09-28 08:56:13.802–ServerSession(712627377)–Thread(Thread[main,5,main])–The column name for element [id] is being defaulted to: ID. Sep 28, 2021 8:56:13 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean buildNativeEntityManagerFactory INFO: Initialized JPA EntityManagerFactory for persistence unit ”EclipseLink_JPA” [EL Info]: 2021-09-28 08:56:14.102–ServerSession(712627377)–Thread(Thread[main,5,main])–EclipseLink, version: Eclipse Persistence Services – 2.5.1.v20130918-f2b9fc5 [EL Fine]: connection: 2021-09-28 08:56:14.403–Thread(Thread[main,5,main])–Detected database platform: org.eclipse.persistence.platform.database.MySQLPlatform [EL Config]: connection: 2021-09-28 08:56:14.423–ServerSession(712627377)–Connection(741883443)–Thread(Thread[main,5,main])–connecting(DatabaseLogin( platform=>MySQLPlatform user name=> “root” datasource URL=> “jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false” )) [EL Config]: connection: 2021-09-28 08:56:14.469–ServerSession(712627377)–Connection(2134915053)–Thread(Thread[main,5,main])–Connected: jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false User: root@localhost Database: MySQL Version: 8.0.23 Driver: MySQL Connector/J Version: mysql-connector-java-8.0.13 (Revision: 66459e9d39c8fd09767992bc592acd2053279be6) [EL Info]: connection: 2021-09-28 08:56:14.539–ServerSession(712627377)–Thread(Thread[main,5,main])–file:/F:/Workspace/springorm/target/classes/_EclipseLink_JPA login successful [EL Fine]: sql: 2021-09-28 08:56:14.602–ServerSession(712627377)–Connection(2134915053)–Thread(Thread[main,5,main])–CREATE TABLE Employees (ID INTEGER AUTO_INCREMENT NOT NULL, DESIGNATION VARCHAR(255), NAME VARCHAR(255), SALARY DOUBLE, PRIMARY KEY (ID)) [EL Fine]: sql: 2021-09-28 08:56:14.836–ClientSession(181326224)–Connection(2134915053)–Thread(Thread[main,5,main])–INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Technical Manager, Julie, 10000.0] [EL Fine]: sql: 2021-09-28 08:56:14.855–ClientSession(181326224)–Connection(2134915053)–Thread(Thread[main,5,main])–SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.883–ClientSession(1573125303)–Connection(2134915053)–Thread(Thread[main,5,main])–INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Senior Manager, Robert, 20000.0] [EL Fine]: sql: 2021-09-28 08:56:14.885–ClientSession(1573125303)–Connection(2134915053)–Thread(Thread[main,5,main])–SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.893–ClientSession(2054787417)–Connection(2134915053)–Thread(Thread[main,5,main])–INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Software Engineer, Anil, 5000.0] [EL Fine]: sql: 2021-09-28 08:56:14.896–ClientSession(2054787417)–Connection(2134915053)–Thread(Thread[main,5,main])–SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.929–ServerSession(712627377)–Connection(2134915053)–Thread(Thread[main,5,main])–SELECT ID, DESIGNATION, NAME, SALARY FROM Employees Id : 1 Name : Julie Salary = 10000.0 Designation = Technical Manager Id : 2 Name : Robert Salary = 20000.0 Designation = Senior Manager Id : 3 Name : Anil Salary = 5000.0 Designation = Software Engineer Sep 28, 2021 8:56:14 AM org.springframework.context.annotation.AnnotationConfigApplicationContext doClose INFO: Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5383967b: startup date [Tue Sep 28 08:56:12 IST 2021]; root of context hierarchy [EL Config]: connection: 2021-09-28 08:56:14.935–ServerSession(712627377)–Connection(2134915053)–Thread(Thread[main,5,main])–disconnect Sep 28, 2021 8:56:14 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean destroy INFO: Closing JPA EntityManagerFactory for persistence unit ”EclipseLink_JPA” [EL Info]: connection: 2021-09-28 08:56:14.936–ServerSession(712627377)–Thread(Thread[main,5,main])–file:/F:/Workspace/springorm/target/classes/_EclipseLink_JPA logout successful [EL Config]: connection: 2021-09-28 08:56:14.936–ServerSession(712627377)–Connection(741883443)–Thread(Thread[main,5,main])–disconnect Here project is built and run using spring configurations. A table Employee is created and have three records. You can verify the same using MySQL console. Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 41 Server version: 8.0.23 MySQL Community Server – GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ”help;” or ”h” for help. Type ”c” to clear the current input statement. mysql> use tutorialspoint; Database changed mysql> select * from employees; +—-+——————-+——–+——–+ | id | DESIGNATION | NAME | SALARY | +—-+——————-+——–+——–+ | 1 | Technical Manager | Julie | 10000 | | 2 | Senior Manager | Robert | 20000 | | 3 | Software Engineer | Anil | 5000 | +—-+——————-+——–+——–+ 3 rows in set (0.00 sec) mysql> Print Page Previous Next Advertisements ”;

Spring ORM – Useful Resources

Spring ORM – Useful Resources ”; Previous Next The following resources contain additional information on Spring ORM. Please use them to get more in-depth knowledge on this topic. Useful Links on Spring ORM Spring Source − Find latest news about Spring Framework, download section and all about Spring. Spring Framework Documentation − Complete Spring Framework reference covering all the modules. Oracle”s Site on JDBC − Sun Developer Network giving link on JDBC material. MySQL Connector/J − MySQL Connector/J is the official JDBC driver for MySQL. The JavaTM Tutorials − The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. JavaTM 2 SDK, Standard Edition − Official site for JavaTM 2 SDK, Standard Edition Free Java Download − Download Java for your desktop computer now! Java Technology Reference − Sun Microsystem”s official website listing down all the API documentation, latest Java Technologies, Books and other resource. Useful Books on Spring ORM To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;

Spring Boot CLI – Environment Setup

Spring Boot CLI – Environment Setup ”; Previous Next Spring is a Java-based framework; hence, we need to set up JDK first. Following are the steps needed to setup Spring Boot CLI along with JDK installation. Step 1 Setup Java Development Kit (JDK) You can download the latest version of SDK from Oracle”s Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively. If you are running Windows and have installed the JDK in C:jdk-11.0.11, you would have to put the following line in your C:autoexec.bat file. set PATH=C:jdk-11.0.11;%PATH% set JAVA_HOME=C:jdk-11.0.11 Alternatively, on Windows NT/2000/XP, you will have to right-click on My Computer, select Properties → Advanced → Environment Variables. Then, you will have to update the PATH value and click the OK button. On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk-11.0.11 and you use the C shell, you will have to put the following into your .cshrc file. setenv PATH /usr/local/jdk-11.0.11/bin:$PATH setenv JAVA_HOME /usr/local/jdk-11.0.11 Step 2 – Install Spring Boot CLI You can download the latest version of Spring Boot CLI API as ZIP archive from https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/. Once you download the installation, unpack the zip distribution into a convenient location. For example, in E:Testspring-boot-cli-2.6.3 on Windows, or /usr/local/spring-boot-cli-2.6.3 on Linux/Unix. Make sure you set your CLASSPATH variable on this directory properly otherwise you will face a problem while running your application. Or set the path in command prompt temporarily to run the spring boot application as shown below − E:/Test/> set path=E:Testspring-boot-cli-2.6.3-binspring-2.6.3bin;%PATH% Step 3 – Verify installation Run the following command on command prompt to verify the installation − E:/Test/> spring –version It should print the following output confirming the successful installation − Spring CLI v2.6.3 Print Page Previous Next Advertisements ”;

Spring Boot JPA – Useful Resources

Spring Boot JPA – Useful Resources ”; Previous Next The following resources contain additional information on Spring Boot JPA. Please use them to get more in-depth knowledge on this. Useful Links on Spring Boot JPA Official Website − Official Website of Spring Boot. Spring Framework − Wikipedia Reference for Spring Boot. Useful Books on Spring Boot JPA To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;