Wednesday, December 26, 2018

spring2-jndi-datasource-conexion

I share example, Spring Boot2 jndi datasource conexion from Tomcat.

Technologies used:

1. Spring Boot 2.0.3.RELEASE
2. Maven 4
3. Java 9
4. Eclipse: Oxygen.1.a Release (4.7.1a)
5. Tomcat 9
6. MySql 5.7.24

Code on GitHub:

https://github.com/HenryXiloj/Spring-boot2-jndi-datasource-conexion



Steps:

1. Create table and insert on table.

CREATE TABLE `user` (
  `id` bigint(20) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `email` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `user` (`id`, `name`, `email`) VALUES ('1', 'Henry', 'test@gmail.com');
INSERT INTO `user` (`id`, `name`, `email`) VALUES ('2', 'Lucas', 'test2@gmail.com');

2.  Add in your context.xml (path_your_tomcat9/conf/context.xml).




3. Import maven project from eclipse.

4. edit configuration file application.properties





5. Run  As -> Run on Server



6. Test: http://localhost:8080/spring2-datasource-conexion/user






References:

https://www.baeldung.com/spring-persistence-jpa-jndi-datasource



No comments:

Post a Comment

Virtual Threads in Java 21: Simplified Concurrency for Modern Applications

  With Java 21, Virtual Threads have redefined how we approach concurrency, offering a lightweight and efficient way to handle parallel and ...