How to configure JNDI datasource for MySQL in Apache Tomcat with Spring Boot web application

Опубликовано: 03 Август 2019
на канале: raksrahul
4,307
32

How to configure JNDI datasource for MySQL in Apache Tomcat with Spring Boot web application.

Spring Boot version : 2.1.6.RELEASE
MySQL connector version : 8.0.16

1. Open Eclipse.

2. Create a runnable spring boot rest application connecting with MySQL database.

3. Move datasource from application.properties to Tomcat JNDI resources.

4. Goto tomcat/conf directory open server.xml and add datasources uniquely identified by 'name' attribute.

5. Define Resource link in tomcat/conf/context.xml file with 'name' attribute value same as of Resource's name in server.xml.

6. Update application.properties in your project with jndi-name (as defined in value of name attribute in Resource).

7. Edit or create a new config class with code

7. Create a war file of your project and deploy it on tomcat server. After deploying application start the server.

8. Test the application. We have test the application that it is able to connect with both schema

9. Finish.

Thank You :)

#java #eclipseide #programming #coding #developer #mysql #jndi #tips #tricks